about summary refs log tree commit diff
path: root/tvix/eval/src/value/string.rs
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2023-01-04T12·29+0100
committerclbot <clbot@tvl.fyi>2023-01-04T12·36+0000
commit9b8ba915c8c006f55c12a8af927810a901e7a378 (patch)
tree33c91072668fa14fa5ad94096a90f2a373852b8f /tvix/eval/src/value/string.rs
parent3d238c350b4c0b4430d694b15e89319a150af889 (diff)
fix(tvix/eval): ' is allowed in nonfirst position in Nix identifiers r/5582
With this is_valid_nix_identifier should line up with the upstream lexer
definition:

    ID          [a-zA-Z\_][a-zA-Z0-9\_\'\-]*

While we're working on this, add a simple test checking the various
formatting rules. Interestingly, it would not be suitable as an identity
test, since you have to write

    { "assert" = null; }

in order to avoid an evaluation error, but C++ Nix is happy to print
this as

    { assert = null; }

– maybe should be considered to be a bug.

Change-Id: I0a4e1ccb5033a80f3767fb8d1c4bba08d303c5d8
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7744
Autosubmit: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix/eval/src/value/string.rs')
-rw-r--r--tvix/eval/src/value/string.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/tvix/eval/src/value/string.rs b/tvix/eval/src/value/string.rs
index 5b2cb83a17de..9ebdf687d284 100644
--- a/tvix/eval/src/value/string.rs
+++ b/tvix/eval/src/value/string.rs
@@ -168,7 +168,7 @@ fn is_valid_nix_identifier(s: &str) -> bool {
     }
     for c in chars {
         match c {
-            'a'..='z' | 'A'..='Z' | '0'..='9' | '_' | '-' => (),
+            'a'..='z' | 'A'..='Z' | '0'..='9' | '_' | '-' | '\'' => (),
             _ => return false,
         }
     }