Skip to content

Commit ab0a2f3

Browse files
committed
internal/core/eval: re-allow ... with embeddings
Fixes #552 Change-Id: I95583aa5f2d532fa10bc54f6be2466b6771f7298 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/7401 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 4cda4a3 commit ab0a2f3

File tree

3 files changed

+78
-4
lines changed

3 files changed

+78
-4
lines changed

cue/testdata/definitions/037_closing_with_comprehensions.txtar

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ a: _|_ // field "f3" not allowed in closed struct
104104
}
105105
-- out/eval --
106106
Errors:
107-
#D: cannot mix bulk optional fields with dynamic fields, embeddings, or comprehensions within the same struct
108107
#E: field `f3` not allowed:
109108
./in.cue:1:5
110109
./in.cue:27:5
@@ -127,8 +126,7 @@ Result:
127126
#C: (#struct){
128127
f1: (int){ int }
129128
}
130-
#D: (_|_){
131-
// [eval] #D: cannot mix bulk optional fields with dynamic fields, embeddings, or comprehensions within the same struct
129+
#D: (#struct){
132130
f1: (int){ int }
133131
}
134132
#E: (_|_){

cue/testdata/eval/embed.txtar

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
-- in.cue --
2+
#A: {
3+
Common
4+
...
5+
}
6+
7+
Common: {
8+
a: int
9+
b: int
10+
}
11+
12+
x: #A
13+
x: {
14+
c: int
15+
}
16+
17+
#B: {
18+
if true {
19+
a: int
20+
}
21+
...
22+
}
23+
24+
y: #B
25+
y: {
26+
c: int
27+
}
28+
29+
-- out/eval --
30+
(struct){
31+
#A: (#struct){
32+
a: (int){ int }
33+
b: (int){ int }
34+
}
35+
Common: (struct){
36+
a: (int){ int }
37+
b: (int){ int }
38+
}
39+
x: (#struct){
40+
a: (int){ int }
41+
b: (int){ int }
42+
c: (int){ int }
43+
}
44+
#B: (#struct){
45+
a: (int){ int }
46+
}
47+
y: (#struct){
48+
c: (int){ int }
49+
a: (int){ int }
50+
}
51+
}
52+
-- out/compile --
53+
--- in.cue
54+
{
55+
#A: {
56+
〈1;Common〉
57+
...
58+
}
59+
Common: {
60+
a: int
61+
b: int
62+
}
63+
x: 〈0;#A〉
64+
x: {
65+
c: int
66+
}
67+
#B: {
68+
if true {
69+
a: int
70+
}
71+
...
72+
}
73+
y: 〈0;#B〉
74+
y: {
75+
c: int
76+
}
77+
}

internal/core/eval/eval.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,6 @@ func (n *nodeContext) addStruct(
15421542
case *adt.Ellipsis:
15431543
n.aStruct = s
15441544
n.aStructID = closeID
1545-
hasBulk = x
15461545
opt.AddEllipsis(ctx, x)
15471546

15481547
default:

0 commit comments

Comments
 (0)