nix::parser::State::addAttr: Deep attribute merging
Closes #845 Change-Id: Ie14d0e5a7a9fb778325c4ad30d1e1bd73c60b4f9
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{ foo = { bar = { baz = 1; qux = 2; }; }; }
|
||||
@@ -0,0 +1,20 @@
|
||||
# Deep recursive attr merges
|
||||
# Regression test for https://git.lix.systems/lix-project/lix/issues/845 / https://github.com/NixOS/nix/issues/11268
|
||||
|
||||
# Also this is an eval test and not a parser test because the printed value is easier to inspect than the AST,
|
||||
# though we are primarily testing parser functionality here
|
||||
let
|
||||
reference = { a.b.c = 1; a.b.d = 2; };
|
||||
in
|
||||
# Test cases courtesy of @rhendric
|
||||
assert { a = { b = { c = 1; }; }; a = { b = { d = 2; }; }; } == reference;
|
||||
assert { a.b = { c = 1; }; a.b = { d = 2; }; } == reference;
|
||||
assert { a = { b.c = 1; }; a = { b.d = 2; }; } == reference;
|
||||
assert { a = { b = { c = 1; }; }; a.b.d = 2; } == reference;
|
||||
assert { a.b.c = 1; a = { b = { d = 2; }; }; } == reference;
|
||||
{
|
||||
foo.bar.baz = 1;
|
||||
foo = {
|
||||
bar.qux = 2;
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
error: attribute 'x.y' already defined at /pwd/in.nix:2:3
|
||||
error: attribute 'x.y.y' already defined at /pwd/in.nix:2:3
|
||||
at /pwd/in.nix:3:9:
|
||||
2| x.y.y = 3;
|
||||
3| x = { y.y= 3; z = 3; };
|
||||
|
||||
Reference in New Issue
Block a user