This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/adt: treat files as belonging to same struct
The bug fix that treats {#A} as #A (2ef72d8) caused this to matter. This fixes that. Also adds a previously forgotten test for embedding definitions, related to this. Change-Id: Ieae00bb2c4c3d537f21b8a5123741a7ffce9a7bd Reviewed-on: https://cue-review.googlesource.com/c/cue/+/8229 Reviewed-by: Paul Jolly <[email protected]> Reviewed-by: CUE cueckoo <[email protected]>
- Loading branch information
Showing
4 changed files
with
132 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
-- in.cue -- | ||
a: { | ||
#A | ||
} | ||
|
||
a: c: 1 | ||
|
||
#A: b: 1 | ||
-- out/eval -- | ||
Errors: | ||
a: field `c` not allowed: | ||
./in.cue:1:4 | ||
./in.cue:2:5 | ||
./in.cue:5:4 | ||
./in.cue:7:5 | ||
|
||
Result: | ||
(_|_){ | ||
// [eval] | ||
a: (_|_){ | ||
// [eval] | ||
b: (int){ 1 } | ||
c: (_|_){ | ||
// [eval] a: field `c` not allowed: | ||
// ./in.cue:1:4 | ||
// ./in.cue:2:5 | ||
// ./in.cue:5:4 | ||
// ./in.cue:7:5 | ||
} | ||
} | ||
#A: (#struct){ | ||
b: (int){ 1 } | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
a: { | ||
〈1;#A〉 | ||
} | ||
a: { | ||
c: 1 | ||
} | ||
#A: { | ||
b: 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,79 @@ | ||
// Treat fields of different files as belonging to the same struct. | ||
// This means that a closed embedding in one file should not restrict the | ||
// fields of another. | ||
|
||
-- in.cue -- | ||
#theme: { | ||
color: string | ||
ctermbg: string | ||
} | ||
dark: #theme & { | ||
color: "dark" | ||
ctermbg: "239" | ||
} | ||
light: #theme & { | ||
color: "light" | ||
ctermbg: "254" | ||
} | ||
#Config: { | ||
console: dark | *light | ||
} | ||
|
||
-- box.cue -- | ||
#Config & { | ||
console: dark | ||
} | ||
|
||
-- out/eval -- | ||
(#struct){ | ||
#theme: (#struct){ | ||
color: (string){ string } | ||
ctermbg: (string){ string } | ||
} | ||
dark: (#struct){ | ||
color: (string){ "dark" } | ||
ctermbg: (string){ "239" } | ||
} | ||
light: (#struct){ | ||
color: (string){ "light" } | ||
ctermbg: (string){ "254" } | ||
} | ||
#Config: (#struct){ | ||
console: (struct){ |(*(#struct){ | ||
color: (string){ "light" } | ||
ctermbg: (string){ "254" } | ||
}, (#struct){ | ||
color: (string){ "dark" } | ||
ctermbg: (string){ "239" } | ||
}) } | ||
} | ||
console: (#struct){ | ||
color: (string){ "dark" } | ||
ctermbg: (string){ "239" } | ||
} | ||
} | ||
-- out/compile -- | ||
--- in.cue | ||
{ | ||
#theme: { | ||
color: string | ||
ctermbg: string | ||
} | ||
dark: (〈0;#theme〉 & { | ||
color: "dark" | ||
ctermbg: "239" | ||
}) | ||
light: (〈0;#theme〉 & { | ||
color: "light" | ||
ctermbg: "254" | ||
}) | ||
#Config: { | ||
console: (〈1;dark〉|*〈1;light〉) | ||
} | ||
} | ||
--- box.cue | ||
{ | ||
(〈0;#Config〉 & { | ||
console: 〈1;dark〉 | ||
}) | ||
} |
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