Fix parsing of variable names that are a prefix of '__curPos'

Fixes

  $ nix-instantiate --parse -E 'x: with x; _'
  (x: (with x; __curPos))
This commit is contained in:
Eelco Dolstra 2022-01-24 15:18:18 +01:00
parent c4fc9b6a8d
commit bed8270c0c
3 changed files with 4 additions and 1 deletions

View file

@ -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));

View file

@ -0,0 +1 @@
3

View file

@ -0,0 +1 @@
((_: _) 1) + ((__: __) 2)