snix/tvix/eval/src/tests
sterni 4ba624efae fix(tvix/eval): use byte, not codepoint index for slicing in escape
This fixes a subtle issue which would occasionally lead to a crash (e.g.
when evaluating (pkgs.systemd.outPath with --trace-runtime): With each
character in the string that has a multi byte representation in UTF-8,
the actual byte position and what tvix thought it was would get out of
sync. This could either lead to

* Tvix swallowing characters or jumbling characters if multi byte
  characters would cause the tracked index to become out of sync with
  the byte position before the first character to be escaped, or

* Tvix crashing if (in the same situation) the out of sync index would
  be within a UTF-8 byte sequence.

Luckily, std's `char_indices()` iterator implements exactly what
`nix_escape_char()`'s original author had in mind with
`.chars().enumerate()`. Using `i + 1` for continuing is safe, since all
characters that need (in fact, can) to be escaped in Nix are represented
as a single byte in UTF-8.

Change-Id: I1c836f70cde3d72db1c644e9112852f0d824715e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8952
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Autosubmit: sterni <sternenseemann@systemli.org>
2023-07-11 16:11:40 +00:00
..
nix_tests test(tvix/eval): update nix_tests suite to C++ Nix master 2023-06-15 19:28:16 +00:00
tvix_tests fix(tvix/eval): use byte, not codepoint index for slicing in escape 2023-07-11 16:11:40 +00:00
mod.rs feat(tvix/eval): allow extending builtins outside of tvix_eval 2023-06-22 20:19:06 +00:00
one_offs.rs fix(tvix/eval): skip runtime completely on compiler errors 2023-02-13 16:21:47 +00:00