diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-01-24 15:18:18 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-01-24 15:18:18 +0100 |
commit | bed8270c0cbaa3007621ad2f0e722abcefe79702 (patch) | |
tree | 04e92115eed32340914d982407ce37f178748210 /src/libexpr/parser.y | |
parent | c4fc9b6a8d4fa279206814295729985dac7bc509 (diff) |
Fix parsing of variable names that are a prefix of '__curPos'
Fixes
$ nix-instantiate --parse -E 'x: with x; _'
(x: (with x; __curPos))
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r-- | src/libexpr/parser.y | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index a3e713937..55f8abcb7 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -404,7 +404,8 @@ expr_select expr_simple : ID { - if (strncmp($1.p, "__curPos", $1.l) == 0) + std::string_view s = "__curPos"; + if (strncmp($1.p, s.data(), s.size()) == 0) $$ = new ExprPos(CUR_POS); else $$ = new ExprVar(CUR_POS, data->symbols.create($1)); |