Merge pull request #5969 from edolstra/curpos-fix

Fix parsing of variable names that are a prefix of '__curPos'
This commit is contained in:
Eelco Dolstra 2022-01-24 16:30:13 +01:00 committed by GitHub
commit e66550c917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 3 deletions

View File

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

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)

View File

@ -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")
]