-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixd/Sema: add lowering support for attrs
- Loading branch information
Showing
9 changed files
with
270 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# RUN: true | ||
|
||
# FIXME: we cannot deal with string_parts currently | ||
# rewrite this test after we can do such thing. | ||
{ | ||
"${bar}" = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# RUN: nixd-lint %s | FileCheck %s | ||
{ | ||
inherit aa; | ||
|
||
# CHECK: duplicated attr `aa` | ||
aa = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# RUN: nixd-lint %s | FileCheck %s | ||
{ | ||
a.bbb = 1; | ||
|
||
# CHECK: error: duplicated attr `b` | ||
a.bbb.c = 2; | ||
|
||
# CHECK: duplicated attr `a` | ||
a = 3; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# RUN: nixd-lint %s | FileCheck %s | ||
{ | ||
|
||
foo = rec { | ||
x = 1; | ||
y = 2; | ||
}; | ||
|
||
# CHECK: merging two attributes with different `rec` modifiers, the latter will be implicitly ignored | ||
# CHECK: this attribute set is recursive | ||
# CHECK: while this attribute set is marked as non-recursive, it will be considered as recursive | ||
foo.bar = 1; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# RUN: nixd-lint %s | FileCheck %s | ||
{ | ||
|
||
foo = rec { | ||
x = 1; | ||
y = 2; | ||
}; | ||
|
||
# CHECK: merging two attributes with different `rec` modifiers, the latter will be implicitly ignored | ||
# CHECK: this attribute set is recursive | ||
# CHECK: while this attribute set is marked as non-recursive, it will be considered as recursive | ||
foo = { | ||
bar = 1; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# RUN: nixd-lint %s | FileCheck %s | ||
rec { | ||
foo.bar = 1; | ||
|
||
# CHECK: merging two attributes with different `rec` modifiers, the latter will be implicitly ignored | ||
|
||
# CHECK: this attribute set is not recursive | ||
# CHECK: while this attribute set is marked as recursive, it will be considered as non-recursive | ||
foo = rec { | ||
x = 1; | ||
y = 2; | ||
}; | ||
} |
12 changes: 12 additions & 0 deletions
12
nixd/tools/nixd-lint/test/lowering-attrset-select-merging.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# RUN: nixd-lint -dump-nix-ast %s | FileCheck %s | ||
|
||
# CHECK: ExprAttrs: { a = { b = 1; c = 2; x = 1; }; } | ||
{ | ||
# CHECK: ExprAttrs: { b = 1; c = 2; x = 1; } | ||
a.b = 1; | ||
a.c = 2; | ||
|
||
a = { | ||
x = 1; | ||
}; | ||
} |