From 3ff6186af1786bd08217bd0b29afb95eacec0f47 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 24 Jan 2022 14:32:25 +0100 Subject: [PATCH 1/3] Add a test for nix-assertion failures in nix-env --- tests/user-envs.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/user-envs.nix b/tests/user-envs.nix index 43eff1a68..6ac896ed8 100644 --- a/tests/user-envs.nix +++ b/tests/user-envs.nix @@ -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") ] From c4fc9b6a8d4fa279206814295729985dac7bc509 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 24 Jan 2022 15:08:16 +0100 Subject: [PATCH 2/3] ExprConcatStrings::show(): Print values instead of pointers --- src/libexpr/nixexpr.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 640c44c01..2d2cd96cd 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -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 << ")"; } From bed8270c0cbaa3007621ad2f0e722abcefe79702 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 24 Jan 2022 15:18:18 +0100 Subject: [PATCH 3/3] Fix parsing of variable names that are a prefix of '__curPos' Fixes $ nix-instantiate --parse -E 'x: with x; _' (x: (with x; __curPos)) --- src/libexpr/parser.y | 3 ++- tests/lang/eval-okay-regression-20220122.exp | 1 + tests/lang/eval-okay-regression-20220122.nix | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/lang/eval-okay-regression-20220122.exp create mode 100644 tests/lang/eval-okay-regression-20220122.nix 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)); diff --git a/tests/lang/eval-okay-regression-20220122.exp b/tests/lang/eval-okay-regression-20220122.exp new file mode 100644 index 000000000..00750edc0 --- /dev/null +++ b/tests/lang/eval-okay-regression-20220122.exp @@ -0,0 +1 @@ +3 diff --git a/tests/lang/eval-okay-regression-20220122.nix b/tests/lang/eval-okay-regression-20220122.nix new file mode 100644 index 000000000..694e9a13b --- /dev/null +++ b/tests/lang/eval-okay-regression-20220122.nix @@ -0,0 +1 @@ +((_: _) 1) + ((__: __) 2)