about summary refs log tree commit diff
path: root/tvix/eval/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2024-01-17 r/7406 fix(tvix/eval): catchable-aware `throw`Ryan Lahfa1-0/+4
`throw (throw "a")` should work and propagate the internal throw. Before this commit, it didn't work. Change-Id: Id5d46f74e484dba99e912ad9fa211f3bf1617bac Reviewed-on: https://cl.tvl.fyi/c/depot/+/10600 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2024-01-17 r/7405 fix(tvix/eval): catchable-aware `elem`Ryan Lahfa1-0/+4
`elem` did not catch the list being a catchable. This surfaced during Nixpkgs evaluation. Change-Id: Icf19b94e914e35a435c4412d769ee63ba59ab7b0 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10599 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2024-01-17 r/7404 feat(tvix/glue): introduce test suite for context stringsRyan Lahfa1-8/+0
This is an additional test suite on the top of the Nix ones for context strings matters. It already smoked out multiple mistakes and potential bugs and non-deterministic result from the evaluator. It uses a similar technology as the one in the tvix-eval albeit we instantiate a fully fledged evaluator with in-memory store. We copy the files instead of symlinking them because crates are built in isolation, so symlinks cannot work. Change-Id: I63ae225ce4f83c6e2c8ccd60d779c2f8eb9d08fb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10619 Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2024-01-17 r/7403 fix(tvix/eval): `getContext` merges underlying valuesRyan Lahfa1-17/+65
Previously, we were assembling very naively an attribute set composed of context we saw. But it was forgetting that `"${drv}${drv.drvPath}"` would contain 2 contexts with the same key, but with different values, one with `outputs = [ "out" ];` and `allOutputs = true;`. Following this reasoning and comparing with what Nix does, we ought to merge underlying values systematically. Hence, I bring `itertools` to perform a group by on the key and merge everything on the fly, it's not beautiful but it's the best I could find, notice that I don't use `group_by` but I talk about group by, that is, because `group_by` is a `group_by_consecutive`, see https://github.com/rust-itertools/itertools/issues/374. Initially, I tried to do it without a `into_grouping_map_by`, it was akin to assemble the final `NixAttrs` directly, it was less readable and harder to pull out because we don't have a lot of in-place mutable functions on our data structures. Change-Id: I9933c9bd88ffe04de50dda14f21879b60d8b8cd4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10620 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-17 r/7400 fix(tvix/eval): context-aware `dirOf`Ryan Lahfa1-1/+1
`dirOf` forgot to accepts contextful strings, e.g. derivations and propagates this context further. Change-Id: I6c05944a3ce5073e243e7676c9be56c48407d657 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10618 Reviewed-by: flokli <flokli@flokli.de> Tested-by: BuildkiteCI
2024-01-17 r/7399 fix(tvix/eval): context-aware… `hasContext`Ryan Lahfa1-1/+1
Yes, `hasContext e` should work where `e` is a contextful strings, otherwise, it is really useless. Change-Id: I5eb071fc257217d6e8a63fe519132ebd98186696 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10617 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2024-01-17 r/7398 feat(tvix/eval): move away from `test_generator` to `rstest`Ryan Lahfa1-28/+43
`test-generator` has not been updated in the past 2 years. `rstest` has not been updated in the past 5 months. This is an improvement in the maintenance state… I guess? We get also new features, it changes the name of the tests with numbers too. Change-Id: I5376104c7704f525dba7524da78daa09867cc669 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10623 Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2024-01-16 r/7395 fix(tvix/eval): lift VM ops over Catchableedef2-115/+102
We want to handle bottoms in a consistent fashion. Previously this was handled by repetitive is_catchable checks, which were not consistently present. Change-Id: I9614c479cc6297d1f64efba22b620a26e2a96802 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10485 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-14 r/7379 fix(tvix/eval): catchable-aware builtinsRyan Lahfa5-38/+306
A bunch of operations in Tvix are not aware of catchable values and does not propagate them. In the meantime, as we wait for a better solution, we just offer this commit for moving the needle. Change-Id: Ic3f0e1550126b0847b597dfc1402c35e0eeef469 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10473 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-12 r/7375 feat(tvix/eval): make into_json publicFlorian Klink1-1/+1
Allow other crates (like tvix-glue) to look at a Value in JSON, which is used by the structured attrs feature. Change-Id: Iba02ace6e11a74c3f9b19dcbef4b008b76dec046 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10602 Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2024-01-12 r/7369 fix(tvix/eval): fix JSON error typesFlorian Klink1-7/+7
The error message is misleading. The errors we return can happen both during serialization or deserialization, though the messages suggested the latter only. Change-Id: I2dafe17ec78ee75cab5937a3a81540fda3175eac Reviewed-on: https://cl.tvl.fyi/c/depot/+/10603 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-05 r/7344 fix(tvix/eval): Update eval benches for new APIAspen Smith1-2/+1
cl/10475 updated the API of tvix_eval::Evaluation, but didn't update this benchmark to use that new API. Also, fixes the docstring to no longer specify that there is a "given snippet". Change-Id: Ibb8285731849dbeec814e2585bbaa36f22368afe Reviewed-on: https://cl.tvl.fyi/c/depot/+/10542 Autosubmit: aspen <root@gws.fyi> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Reviewed-by: flokli <flokli@flokli.de>
2024-01-03 r/7340 feat(tvix/eval): context-aware `split`Ryan Lahfa1-5/+14
Nix does something like: ```cpp NixStringContext context; const auto str = state.forceString(*args[1], context, pos, "while evaluating the second argument passed to builtins.split"); ``` And then do nothing with that context, therefore, we follow them and make `split` aware of the context but still do nothing with it. Change-Id: I4fee1936600ce86d99d00893ca3f64013213935b Reviewed-on: https://cl.tvl.fyi/c/depot/+/10428 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7339 feat(tvix/eval): impl `unsafeDiscardStringContext`Ryan Lahfa1-4/+19
Change-Id: I7f0cc42cbebfe5cd27bf6d4f58a4af927b83646a Reviewed-on: https://cl.tvl.fyi/c/depot/+/10423 Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-03 r/7336 feat(tvix/glue): context-aware `toFile`Ryan Lahfa1-0/+9
This removes the reference tracking and uses instead the context for references and returns some. Change-Id: Ic359ca6b903b63f1a9c679c566004c617b792442 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10435 Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-03 r/7335 feat(tvix/eval): contextful coercion of filesRyan Lahfa1-0/+5
In the past reference tracking system, `tvix-io` glue was appending plain paths in the known path state. Now, we make up for this by just making contextful coercion of file imports. Change-Id: Ieb9b04dd83302c77909252d5f7733857ac3cf8fd Reviewed-on: https://cl.tvl.fyi/c/depot/+/10443 Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-03 r/7334 feat(tvix/eval): contextful string coercionRyan Lahfa1-1/+1
String with contexts are always coerced to a string with the same context. Change-Id: I224814febd9cad196bb28876793e76bed564dc72 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10440 Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: sterni <sternenseemann@systemli.org>
2024-01-03 r/7333 feat(tvix/eval): contextful == of derivationsRyan Lahfa1-2/+6
Otherwise, you just fail because they are not... contextless strings! Change-Id: I0b8f63a18cd89c3841b613d41c12ec4ee336f953 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10442 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2024-01-03 r/7332 feat(tvix/eval): `match` DO NOT propagate contextRyan Lahfa1-6/+13
`match` silently ignore the input context and do not propagate it and successful matches. The why is unclear but nixpkgs does rely implicitly on this behavior because dynamic attribute selection cannot be done with contextful strings. Change-Id: I5167fa9b2c2db8ecab0c2fb3e9895c9cfce6eeb2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10441 Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-03 r/7331 feat(tvix/eval): implement `getContext` primopRyan Lahfa2-0/+47
Change-Id: I2c5068a28f9883a01b0ff80a5e5ab32ba18bfc1a Reviewed-on: https://cl.tvl.fyi/c/depot/+/10437 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2024-01-03 r/7330 feat(tvix/eval): context-aware `replaceStrings`Ryan Lahfa1-6/+23
And it also preserve the original context if it exists. Change-Id: I904f7c13b7f003a267aace6301723780fccaafb7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10434 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7329 chore(tvix/eval): note on context-aware `hashString`Ryan Lahfa1-0/+1
It must propagate context too. Change-Id: If57c22c9723ea02aa013f69d3dcf96054476d8de Reviewed-on: https://cl.tvl.fyi/c/depot/+/10433 Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-03 r/7328 feat(tvix/eval): `${}` propagates contextsRyan Lahfa1-4/+13
We just perform union of contexts of every pieces. Change-Id: Ief925c1818cd8bbec0503e9c625b0630feebfdda Reviewed-on: https://cl.tvl.fyi/c/depot/+/10432 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7327 feat(tvix/eval): context-aware `concatStringsSep`Ryan Lahfa1-3/+19
Change-Id: Id0e169084d26dc598091d157563c4d959b66279b Reviewed-on: https://cl.tvl.fyi/c/depot/+/10431 Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-03 r/7326 chore(tvix/eval): note on context-aware `toString`Ryan Lahfa1-0/+2
Change-Id: Ie26ebd16e95e6a7b6f81051d8269169842978058 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10430 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7325 feat(tvix/eval): context-aware `throw`Ryan Lahfa1-1/+2
Change-Id: Ie552dabe4cf93cc396c883268a3bee67796dbbd8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10429 Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2024-01-03 r/7324 feat(tvix/eval): context-aware `substring`Ryan Lahfa1-3/+6
`substring` has a very funny behavior when it comes to empty strings, it propagates the context too, this is used in nixpkgs to attach context to strings without using any builtin: `lib.addContextFrom`. Change-Id: Id655356799b3485f7519b3d1914c630f9d8416c3 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10448 Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-03 r/7323 feat(tvix/eval): context-aware `abort`Ryan Lahfa1-1/+5
Change-Id: Id5a435961ce3a2a2240b3936ea48515650d445d6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10427 Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2024-01-03 r/7320 feat(tvix/eval): context-aware `dirOf`Ryan Lahfa1-1/+3
Change-Id: If73a82a7106de9b479c950741efb70bffabd470a Reviewed-on: https://cl.tvl.fyi/c/depot/+/10424 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2024-01-03 r/7319 feat(tvix/eval): context-aware `baseNameOf`Ryan Lahfa1-2/+5
Change-Id: I9f0a8143070805b85276f721bdfbdf7ede2cf615 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10421 Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2024-01-03 r/7318 chore(tvix/eval): notes on coercion and contextsRyan Lahfa1-0/+3
We make a case for adding a `reject_context` `CoercionKind` here. It does happen during concatenation actually for path concats. Change-Id: I0c196aad917550b9bcd0896cd2127a94f8181ffb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10444 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7317 feat(tvix/eval): context-aware `coerce_to_string`Ryan Lahfa2-2/+18
I am still undecided whether we need a CoercionKind to control the coerced context, here's a simple attempt. Change-Id: Ibe59d09ef26c519a6acfdfe392014446646dd6d8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10426 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7311 feat(tvix/glue): emit a warning in case of bad SRI hashesFlorian Klink1-0/+3
And include a test to ensure we show the warning. Change-Id: Ib6a436dbba2592b398b54e44f15a48d1aa345099 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10470 Tested-by: BuildkiteCI Reviewed-by: raitobezarius <tvl@lahfa.xyz>
2024-01-03 r/7310 feat(tvix/eval): emit warnings with kinds and spansRyan Lahfa1-7/+5
In the past, we had `emit_warning` be no-op and we used `push_warnings` exclusively but as we have consumers of this function, we need it to work somewhat. Change-Id: I78a5ece199a473dec9ef5ea1fae60b36e35137b8 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10477 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: flokli <flokli@flokli.de>
2023-12-31 r/7290 feat(tvix/eval): accept impl AsRef<str> for codeFlorian Klink2-7/+15
We're also happy to consume strings, or other owned stringy types. Change-Id: I5bead4407976134815d8f879f9f70468e6af1dc4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10476 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
2023-12-31 r/7289 refactor(tvix/eval): remove code and location from structFlorian Klink3-53/+56
Instead, it's passed in the evaluate/compile_only functions, which feels more naturally. It lets us set up the Evaluation struct long before we actually feed it with data to evaluate. Now that Evaluation::new() would be accepting an empty list of arguments, we can simply implement Default, making things a bit more idiomatic. Change-Id: I4369658634909a0c504fdffa18242a130daa0239 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10475 Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su> Autosubmit: flokli <flokli@flokli.de>
2023-12-29 r/7282 feat(tvix/eval): context-aware casting to stringsRyan Lahfa1-2/+23
By default, we don't want contextful strings and we almost always want contextless strings. To this end, we make taking a contextful string a very explicit operation under `to_contextful_str` and we implement manually the `to_str` cast which requires a `if !s.has_context()` guard that the macro cannot cover. Change-Id: I7aae8e57a7d73e547e62b1edb0b1cc7e8c0c69b6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10425 Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-12-29 r/7281 feat(tvix/eval): implement `hasContext` primopRyan Lahfa1-4/+3
`hasContext` is now functional. Change-Id: I23b128afc9150b833bc0d9b042d31fee35badadb Reviewed-on: https://cl.tvl.fyi/c/depot/+/10422 Tested-by: BuildkiteCI Autosubmit: raitobezarius <tvl@lahfa.xyz> Reviewed-by: tazjin <tazjin@tvl.su>
2023-12-29 r/7280 feat(tvix/eval): introduce `NixContext`Ryan Lahfa3-7/+193
This prepares the data structures to implement string contexts in Nix. Change-Id: Idd913c9c881daeb8d446907f4b940e462e730978 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10420 Autosubmit: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
2023-12-29 r/7277 fix(tvix/eval): propagate catchables through builtins.attrNamesAdam Joseph3-0/+5
Change-Id: Id14e39543239272aed041998fd9a78465c9cb8b2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10359 Autosubmit: Adam Joseph <adam@westernsemico.com> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2023-12-29 r/7276 fix(tvix/eval): propagate catchables through builtins.intersectAttrsAdam Joseph3-0/+8
Change-Id: I4ada8cf10611e98519cb1b1da11bfd06815f2932 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10358 Autosubmit: Adam Joseph <adam@westernsemico.com> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2023-12-29 r/7275 fix(tvix/eval): propagate catchables in string interpolationsAdam Joseph3-2/+12
Change-Id: I13d7ce0c7328a8e6fbc6d2c4ff5c4fe6095b96ea Reviewed-on: https://cl.tvl.fyi/c/depot/+/10357 Autosubmit: Adam Joseph <adam@westernsemico.com> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2023-12-29 r/7274 fix(tvix/eval): catchable in type field of nix_eq()Adam Joseph5-8/+26
Change-Id: I165ff77764e272cc94d18cb03ad6cbc9a8ebefde Reviewed-on: https://cl.tvl.fyi/c/depot/+/10348 Autosubmit: Adam Joseph <adam@westernsemico.com> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2023-12-29 r/7273 fix(tvix/eval): builtins.match: propagate catchablesAdam Joseph3-2/+12
Change-Id: I14c9e625c91369e10d0c00380dca992811ae9059 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10346 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: Adam Joseph <adam@westernsemico.com> Tested-by: BuildkiteCI
2023-12-29 r/7272 refactor(tvix/eval): let OpCoerceToString select the CoercionKindAdam Joseph4-15/+13
Change-Id: I92d58ef216d7e0766af70f019b3dcd445284a95d Reviewed-on: https://cl.tvl.fyi/c/depot/+/10344 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-12-29 r/7271 fix(tvix/eval): add stack depth assertion to OpReturnAdam Joseph1-0/+7
I'm still trying to work out the exact stack invariants for tvix. We really should add assertions for them; getting the stack messed up is no fun. This commit adds one simple assertion. It also adds a missing stack-push (my mistake) in one place, which was uncovered by the assertion. Change-Id: I9d8b4bd1702d954e325832c5935b0d7e3eb68422 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10369 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
2023-12-25 r/7264 fix(tvix/eval/value): correctly emit spaces when coercing listssterni3-16/+36
r/7176 introduced an incorrect assumption was the benefit of the nonrecursive coercion algorithm, namely that a coercion operation always returns a non empty string. This allows to detect whether we are coercing a list or not by checking if the intermediate result is empty or not. Unfortunately, coercing null and false yields an empty string, so we need to explicitly track whether we are coercing a list. Updated the test case to hopefully catch similar bugs in the future. I'm not a hundred percent certain I have not introduced a new edge case with this, so it may be interesting to add a prop test case for this to nix_oracle down the line. At least lists are the only nested data structures that can be serialized as nested data structures, so the problem is kind of limited. Change-Id: Ia41e904356f1c41a9d35e4e65ec02f2fe5a4100e Reviewed-on: https://cl.tvl.fyi/c/depot/+/10418 Reviewed-by: raitobezarius <tvl@lahfa.xyz> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
2023-12-14 r/7218 fix(tvix/eval): remove incorrect imports when coercingsterni7-49/+193
The default behavior of string coercion in C++ Nix is to weakly coerce and import to store if necessary. There is a flag to make it strongly coerce (coerceMore) and a flag that controls whether path values have the corresponding file/directory imported into the store before returning the (store) path as a string (copyToStore). We need to implement our equivalent to the copyToStore (import_paths) flag for the benefit of weak coercions that don't import into the store (dirOf, baseNameOf, readFile, ...) and strong coercions that don't import into the store (toString). This makes coerce_to_string as well as CoercionKind weirder and more versatile, but prevents us from reimplementing parts of the coercion logic constantly as can be seen in the case of baseNameOf. Note that it is not possible to test this properly in //tvix/eval tests due to the lack of an appropriate EvalIO implementation being available. Tests should be added to //tvix/glue down the line. Change-Id: I8fb8ab99c7fe08e311d2ba1c36960746bf22f566 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10361 Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI Reviewed-by: Adam Joseph <adam@westernsemico.com>
2023-12-14 r/7217 fix(tvix/eval): determine meaning of `+` exprs based on first typesterni1-5/+11
This matches the behavior of C++ Nix more closely where the decision is made based on the first type based to ExprConcatStrings: https://github.com/NixOS/nix/blob/1f93fa2ed29ff0ba92bfa58995232668187fb0d0/src/libexpr/eval.cc#L1967-L2025 Note that this doesn't make a difference in any successful evaluation (at least to my knowledge), but ensures that our error messages will match C++ Nix more closely, e.g. in the case of `1 + "string"`. Change-Id: I8059930788f9c8d98baf98e3d93d8a060ef961f2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10360 Tested-by: BuildkiteCI Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: Adam Joseph <adam@westernsemico.com>
2023-12-12 r/7206 refactor(tvix/eval): vm::add_values(): be less verboseAdam Joseph1-12/+8
Change-Id: Icf328649fd70bdf0fc3ba6cd7754ae29735f11f7 Reviewed-on: https://cl.tvl.fyi/c/depot/+/10035 Autosubmit: Adam Joseph <adam@westernsemico.com> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>