diff options
author | sterni <sternenseemann@systemli.org> | 2022-09-14T13·35+0200 |
---|---|---|
committer | sterni <sternenseemann@systemli.org> | 2022-09-15T15·52+0000 |
commit | bcd7e520f076fb7a6b26805663fac2d70c677bc8 (patch) | |
tree | 69b249c5768b8f3d06b7a1b838e9b2f954568c90 /tvix/eval/src/tests | |
parent | b570da18d651df8a513a921fd4deb6474bb72d45 (diff) |
fix(tvix/eval): thunk string interpolation r/4859
If we have multiple string parts, we need to thunk assembling the string. If we have a single literal, it is strict (like all literals), but a single interpolation part may compile to a thunk, depending on how the expression inside is compiled – we can avoid forcing to early here compared to the previous behavior. Note that this CL retains the bug that `"${x}"` is erroneously translated to `x`, implying e.g. `"${12}" == 12`. The use of `parts.len()` is unproblematic, since normalized_parts() builds a `Vec` instead of returning an iterator. Change-Id: I3aecbfefef65cc627b1b8a65be27cbaeada3582b Reviewed-on: https://cl.tvl.fyi/c/depot/+/6580 Autosubmit: sterni <sternenseemann@systemli.org> Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/tests')
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.exp | 1 | ||||
-rw-r--r-- | tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.nix | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.exp b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.exp new file mode 100644 index 000000000000..fc2f21e9305c --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.exp @@ -0,0 +1 @@ +"strict literal" diff --git a/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.nix b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.nix new file mode 100644 index 000000000000..bd3555bb2412 --- /dev/null +++ b/tvix/eval/src/tests/tvix_tests/eval-okay-thunked-string-interpolation.nix @@ -0,0 +1,7 @@ +let + final = { text = "strict literal"; inherit x y; }; + x = "lazy ${throw "interpolation"}"; + y = "${throw "also lazy!"}"; +in + +final.text |