Merge pull request #5969 from edolstra/curpos-fix
Fix parsing of variable names that are a prefix of '__curPos'
This commit is contained in:
commit
e66550c917
|
@ -191,7 +191,7 @@ void ExprConcatStrings::show(std::ostream & str) const
|
|||
str << "(";
|
||||
for (auto & i : *es) {
|
||||
if (first) first = false; else str << " + ";
|
||||
str << i.second;
|
||||
str << *i.second;
|
||||
}
|
||||
str << ")";
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
1
tests/lang/eval-okay-regression-20220122.exp
Normal file
1
tests/lang/eval-okay-regression-20220122.exp
Normal file
|
@ -0,0 +1 @@
|
|||
3
|
1
tests/lang/eval-okay-regression-20220122.nix
Normal file
1
tests/lang/eval-okay-regression-20220122.nix
Normal file
|
@ -0,0 +1 @@
|
|||
((_: _) 1) + ((__: __) 2)
|
|
@ -9,7 +9,8 @@ assert foo == "foo";
|
|||
let
|
||||
|
||||
makeDrv = name: progName: (mkDerivation {
|
||||
inherit name progName system;
|
||||
name = assert progName != "fail"; name;
|
||||
inherit progName system;
|
||||
builder = ./user-envs.builder.sh;
|
||||
} // {
|
||||
meta = {
|
||||
|
@ -26,4 +27,5 @@ in
|
|||
(makeDrv "foo-2.0" "foo")
|
||||
(makeDrv "bar-0.1.1" "bar")
|
||||
(makeDrv "foo-0.1" "foo" // { meta.priority = 10; })
|
||||
(makeDrv "fail-0.1" "fail")
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue