Skip to content

Commit

Permalink
internal/core/eval: re-allow ... with embeddings
Browse files Browse the repository at this point in the history
Fixes #552

Change-Id: I95583aa5f2d532fa10bc54f6be2466b6771f7298
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7401
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Oct 8, 2020
1 parent 4cda4a3 commit ab0a2f3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ a: _|_ // field "f3" not allowed in closed struct
}
-- out/eval --
Errors:
#D: cannot mix bulk optional fields with dynamic fields, embeddings, or comprehensions within the same struct
#E: field `f3` not allowed:
./in.cue:1:5
./in.cue:27:5
Expand All @@ -127,8 +126,7 @@ Result:
#C: (#struct){
f1: (int){ int }
}
#D: (_|_){
// [eval] #D: cannot mix bulk optional fields with dynamic fields, embeddings, or comprehensions within the same struct
#D: (#struct){
f1: (int){ int }
}
#E: (_|_){
Expand Down
77 changes: 77 additions & 0 deletions cue/testdata/eval/embed.txtar
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- in.cue --
#A: {
Common
...
}

Common: {
a: int
b: int
}

x: #A
x: {
c: int
}

#B: {
if true {
a: int
}
...
}

y: #B
y: {
c: int
}

-- out/eval --
(struct){
#A: (#struct){
a: (int){ int }
b: (int){ int }
}
Common: (struct){
a: (int){ int }
b: (int){ int }
}
x: (#struct){
a: (int){ int }
b: (int){ int }
c: (int){ int }
}
#B: (#struct){
a: (int){ int }
}
y: (#struct){
c: (int){ int }
a: (int){ int }
}
}
-- out/compile --
--- in.cue
{
#A: {
〈1;Common〉
...
}
Common: {
a: int
b: int
}
x: 〈0;#A〉
x: {
c: int
}
#B: {
if true {
a: int
}
...
}
y: 〈0;#B〉
y: {
c: int
}
}
1 change: 0 additions & 1 deletion internal/core/eval/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,6 @@ func (n *nodeContext) addStruct(
case *adt.Ellipsis:
n.aStruct = s
n.aStructID = closeID
hasBulk = x
opt.AddEllipsis(ctx, x)

default:
Expand Down

0 comments on commit ab0a2f3

Please sign in to comment.