Skip to content

Commit 2491cac

Browse files
committed
internal/core/adt: add tests for Issue 3576
The extra node errors are a result of the added code and are not a new bug. Issue #3576 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Iaf762131b946d7efaee64b218c48a3ea34b56488 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206290 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent c21e546 commit 2491cac

File tree

2 files changed

+244
-8
lines changed

2 files changed

+244
-8
lines changed

cue/testdata/disjunctions/errors.txtar

Lines changed: 243 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,49 @@ issue3581: reduced: {
4747
list: ["\(c)" ]
4848
c: _
4949
}
50+
-- issue3576.cue --
51+
issue3576: reduced: {
52+
#A: a!: string
53+
#B: {
54+
if false {
55+
dummy: {}
56+
}
57+
}
58+
foo: #B | #A
59+
foo: a: "1"
60+
}
61+
issue3576: full: {
62+
#Run: {
63+
run!: string
64+
options?: #Option | [#Option, ...]
65+
if options != _|_ {
66+
optionsValue: options
67+
}
68+
}
69+
70+
#Copy: {
71+
copy!: string
72+
options?: #Option | [#Option, ...]
73+
if options != _|_ {
74+
optionsValue: options
75+
}
76+
}
77+
78+
#Option: {}
79+
80+
foo: #Run | #Copy
81+
foo: run: "make"
82+
}
5083
-- out/eval/stats --
5184
Leaks: 0
52-
Freed: 65
53-
Reused: 56
54-
Allocs: 9
55-
Retain: 20
85+
Freed: 109
86+
Reused: 99
87+
Allocs: 10
88+
Retain: 21
5689

57-
Unifications: 39
58-
Conjuncts: 96
59-
Disjuncts: 85
90+
Unifications: 71
91+
Conjuncts: 152
92+
Disjuncts: 130
6093
-- out/evalalpha --
6194
Errors:
6295
issue516.x: 2 errors in empty disjunction:
@@ -140,6 +173,64 @@ Result:
140173
issue3157: (struct){
141174
foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
142175
}
176+
issue3576: (struct){
177+
reduced: (struct){
178+
#A: (#struct){
179+
a!: (string){ string }
180+
}
181+
#B: (#struct){
182+
}
183+
foo: (struct){ |((#struct){
184+
a: (_|_){
185+
// [eval] issue3576.reduced.foo.a: field not allowed:
186+
// ./issue3576.cue:5:11
187+
// ./issue3576.cue:9:7
188+
}
189+
}, (#struct){
190+
a: (string){ "1" }
191+
}) }
192+
}
193+
full: (struct){
194+
#Run: (#struct){
195+
run!: (string){ string }
196+
options?: ((list|struct)){ |((#struct){
197+
}, (list){
198+
0: (#struct){
199+
}
200+
}) }
201+
}
202+
#Copy: (#struct){
203+
copy!: (string){ string }
204+
options?: ((list|struct)){ |((#struct){
205+
}, (list){
206+
0: (#struct){
207+
}
208+
}) }
209+
}
210+
#Option: (#struct){
211+
}
212+
foo: (struct){ |((#struct){
213+
run: (string){ "make" }
214+
options?: ((list|struct)){ |((#struct){
215+
}, (list){
216+
0: (#struct){
217+
}
218+
}) }
219+
}, (#struct){
220+
run: (_|_){
221+
// [eval] issue3576.full.foo.run: field not allowed:
222+
// ./issue3576.cue:24:18
223+
// ./issue3576.cue:31:7
224+
}
225+
copy!: (string){ string }
226+
options?: ((list|struct)){ |((#struct){
227+
}, (list){
228+
0: (#struct){
229+
}
230+
}) }
231+
}) }
232+
}
233+
}
143234
issue3581: (struct){
144235
reduced: (struct){
145236
list: (_|_){
@@ -224,7 +315,7 @@ diff old new
224315
metrics: (struct){
225316
foo: (struct){
226317
}
227-
@@ -86,23 +74,21 @@
318+
@@ -86,11 +74,11 @@
228319
}
229320
issue2916: (struct){
230321
b: (struct){
@@ -236,7 +327,63 @@ diff old new
236327
- foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
237328
+ foo: ((bool|int)){ |((int){ 43 }, (bool){ bool }) }
238329
}
330+
issue3576: (struct){
331+
reduced: (struct){
332+
@@ -99,9 +87,15 @@
333+
}
334+
#B: (#struct){
335+
}
336+
- foo: (#struct){
337+
- a: (string){ "1" }
338+
- }
339+
+ foo: (struct){ |((#struct){
340+
+ a: (_|_){
341+
+ // [eval] issue3576.reduced.foo.a: field not allowed:
342+
+ // ./issue3576.cue:5:11
343+
+ // ./issue3576.cue:9:7
344+
+ }
345+
+ }, (#struct){
346+
+ a: (string){ "1" }
347+
+ }) }
348+
}
349+
full: (struct){
350+
#Run: (#struct){
351+
@@ -122,14 +116,26 @@
352+
}
353+
#Option: (#struct){
354+
}
355+
- foo: (#struct){
356+
- run: (string){ "make" }
357+
- options?: ((list|struct)){ |((#struct){
358+
- }, (list){
359+
- 0: (#struct){
360+
- }
361+
- }) }
362+
- }
363+
+ foo: (struct){ |((#struct){
364+
+ run: (string){ "make" }
365+
+ options?: ((list|struct)){ |((#struct){
366+
+ }, (list){
367+
+ 0: (#struct){
368+
+ }
369+
+ }) }
370+
+ }, (#struct){
371+
+ run: (_|_){
372+
+ // [eval] issue3576.full.foo.run: field not allowed:
373+
+ // ./issue3576.cue:24:18
374+
+ // ./issue3576.cue:31:7
375+
+ }
376+
+ copy!: (string){ string }
377+
+ options?: ((list|struct)){ |((#struct){
378+
+ }, (list){
379+
+ 0: (#struct){
380+
+ }
381+
+ }) }
382+
+ }) }
383+
}
384+
}
239385
issue3581: (struct){
386+
@@ -136,13 +142,11 @@
240387
reduced: (struct){
241388
list: (_|_){
242389
// [incomplete] issue3581.reduced.list: 2 errors in empty disjunction:
@@ -359,6 +506,46 @@ Result:
359506
issue3157: (struct){
360507
foo: ((bool|int)){ |(*(int){ 43 }, (bool){ bool }) }
361508
}
509+
issue3576: (struct){
510+
reduced: (struct){
511+
#A: (#struct){
512+
a!: (string){ string }
513+
}
514+
#B: (#struct){
515+
}
516+
foo: (#struct){
517+
a: (string){ "1" }
518+
}
519+
}
520+
full: (struct){
521+
#Run: (#struct){
522+
run!: (string){ string }
523+
options?: ((list|struct)){ |((#struct){
524+
}, (list){
525+
0: (#struct){
526+
}
527+
}) }
528+
}
529+
#Copy: (#struct){
530+
copy!: (string){ string }
531+
options?: ((list|struct)){ |((#struct){
532+
}, (list){
533+
0: (#struct){
534+
}
535+
}) }
536+
}
537+
#Option: (#struct){
538+
}
539+
foo: (#struct){
540+
run: (string){ "make" }
541+
options?: ((list|struct)){ |((#struct){
542+
}, (list){
543+
0: (#struct){
544+
}
545+
}) }
546+
}
547+
}
548+
}
362549
issue3581: (struct){
363550
reduced: (struct){
364551
list: (_|_){
@@ -430,6 +617,54 @@ Result:
430617
foo: (*43|bool)
431618
}
432619
}
620+
--- issue3576.cue
621+
{
622+
issue3576: {
623+
reduced: {
624+
#A: {
625+
a!: string
626+
}
627+
#B: {
628+
if false {
629+
dummy: {}
630+
}
631+
}
632+
foo: (〈0;#B〉|〈0;#A〉)
633+
foo: {
634+
a: "1"
635+
}
636+
}
637+
}
638+
issue3576: {
639+
full: {
640+
#Run: {
641+
run!: string
642+
options?: (〈1;#Option〉|[
643+
〈2;#Option〉,
644+
...,
645+
])
646+
if (〈0;options〉 != _|_(explicit error (_|_ literal) in source)) {
647+
optionsValue: 〈1;options〉
648+
}
649+
}
650+
#Copy: {
651+
copy!: string
652+
options?: (〈1;#Option〉|[
653+
〈2;#Option〉,
654+
...,
655+
])
656+
if (〈0;options〉 != _|_(explicit error (_|_ literal) in source)) {
657+
optionsValue: 〈1;options〉
658+
}
659+
}
660+
#Option: {}
661+
foo: (〈0;#Run〉|〈0;#Copy〉)
662+
foo: {
663+
run: "make"
664+
}
665+
}
666+
}
667+
}
433668
--- issue3581.cue
434669
{
435670
issue3581: {

internal/core/adt/eval_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ var skipDebugDepErrors = map[string]int{
8686
"cycle/disjunction": 4,
8787
"cycle/structural": 14,
8888
"disjunctions/edge": 1,
89+
"disjunctions/errors": 2,
8990
"disjunctions/elimination": 11,
9091
"disjunctions/embed": 6,
9192
"eval/conjuncts": 3,

0 commit comments

Comments
 (0)