Skip to content

Commit

Permalink
internal/core/adt: add tests for issue 3491
Browse files Browse the repository at this point in the history
To be immediately followed with fix.

Issue #3491

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I86d2bfaa20600956bd3118fce07f71d1c4bff9f5
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202460
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Oct 11, 2024
1 parent 0dd7f69 commit 9ba55dc
Showing 1 changed file with 114 additions and 26 deletions.
140 changes: 114 additions & 26 deletions cue/testdata/definitions/fields.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,27 @@ issue1830: {
}
}
}
-- issue3491.cue --
issue3491: {
#Schema: field?: {}

a: #Schema & {
field: {}
}

a: b
b: #Extra: {}
}
-- out/eval/stats --
Leaks: 3
Freed: 210
Reused: 203
Freed: 218
Reused: 211
Allocs: 10
Retain: 19
Retain: 20

Unifications: 213
Conjuncts: 388
Disjuncts: 229
Unifications: 221
Conjuncts: 402
Disjuncts: 238
-- out/evalalpha --
Errors:
err.t2.V.c.e: field not allowed:
Expand Down Expand Up @@ -253,6 +264,8 @@ issue1830.egs.x1.age1: field not allowed:
issue1830.egs.x2.age2: field not allowed:
./issue1830.cue:15:7
./issue1830.cue:17:4
issue3491.a.#Extra: field not allowed:
./issue3491.cue:8:5

Result:
(_|_){
Expand Down Expand Up @@ -680,12 +693,32 @@ Result:
}
}
}
issue3491: (_|_){
// [eval]
#Schema: (#struct){
field?: (#struct){
}
}
a: (_|_){
// [eval]
field: (#struct){
}
#Extra: (_|_){
// [eval] issue3491.a.#Extra: field not allowed:
// ./issue3491.cue:8:5
}
}
b: (struct){
#Extra: (#struct){
}
}
}
}
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,60 +1,37 @@
@@ -1,60 +1,39 @@
Errors:
-err.t1.a.disallowed: field not allowed:
- ./in.cue:128:10
Expand Down Expand Up @@ -761,10 +794,12 @@ diff old new
+issue1830.egs.x2.age2: field not allowed:
+ ./issue1830.cue:15:7
+ ./issue1830.cue:17:4
+issue3491.a.#Extra: field not allowed:
+ ./issue3491.cue:8:5

Result:
(_|_){
@@ -63,7 +40,7 @@
@@ -63,7 +42,7 @@
// [eval]
t1: (struct){
c: (#list){
Expand All @@ -773,7 +808,7 @@ diff old new
b: (int){ int }
}
}
@@ -72,7 +49,7 @@
@@ -72,7 +51,7 @@
}
t2: (struct){
#A: (_){ _ }
Expand All @@ -782,7 +817,7 @@ diff old new
f: (string){ "hi" }
}
}
@@ -102,11 +79,11 @@
@@ -102,11 +81,11 @@
}
}
W: (#struct){
Expand All @@ -799,7 +834,7 @@ diff old new
}
}
}
@@ -120,10 +97,7 @@
@@ -120,10 +99,7 @@
// [eval]
c: (_|_){
// [eval] ok.t5.x.c: field not allowed:
Expand All @@ -810,7 +845,7 @@ diff old new
// ./in.cue:41:5
}
}
@@ -156,16 +130,7 @@
@@ -156,16 +132,7 @@
}
}
t8: (struct){
Expand All @@ -828,7 +863,7 @@ diff old new
#X: (#struct){
a: (#struct){
b: (#struct){
@@ -179,7 +144,7 @@
@@ -179,7 +146,7 @@
}
t9: (struct){
c: (#list){
Expand All @@ -837,7 +872,7 @@ diff old new
b: (int){ int }
}
}
@@ -188,7 +153,7 @@
@@ -188,7 +155,7 @@
}
t10: (struct){
#A: (_){ _ }
Expand All @@ -846,7 +881,7 @@ diff old new
f: (string){ "hi" }
}
}
@@ -218,11 +183,11 @@
@@ -218,11 +185,11 @@
}
}
W: (#struct){
Expand All @@ -863,7 +898,7 @@ diff old new
}
}
}
@@ -236,10 +201,7 @@
@@ -236,10 +203,7 @@
// [eval]
c: (_|_){
// [eval] ok.t13.x.c: field not allowed:
Expand All @@ -874,7 +909,7 @@ diff old new
// ./in.cue:112:5
}
}
@@ -263,13 +225,12 @@
@@ -263,13 +227,12 @@
}
a: (_|_){
// [eval]
Expand All @@ -889,7 +924,7 @@ diff old new
}
}
t2: (_|_){
@@ -283,14 +244,11 @@
@@ -283,14 +246,11 @@
// [eval]
c: (_|_){
// [eval]
Expand All @@ -905,15 +940,15 @@ diff old new
}
}
}
@@ -304,7 +262,6 @@
@@ -304,7 +264,6 @@
// [eval]
c: (_|_){
// [eval] err.t3.p1.a.c: field not allowed:
- // ./in.cue:140:6
// ./in.cue:141:5
// ./in.cue:142:5
}
@@ -322,8 +279,6 @@
@@ -322,8 +281,6 @@
// [eval]
c: (_|_){
// [eval] err.t3.p2.a.b.c: field not allowed:
Expand All @@ -922,7 +957,7 @@ diff old new
// ./in.cue:148:8
}
}
@@ -336,54 +291,47 @@
@@ -336,54 +293,47 @@
// [eval]
b: (_|_){
// [eval]
Expand Down Expand Up @@ -1010,7 +1045,7 @@ diff old new
}
}
}
@@ -433,17 +381,12 @@
@@ -433,17 +383,12 @@
// [eval]
e: (_|_){
// [eval]
Expand All @@ -1030,7 +1065,7 @@ diff old new
}
}
}
@@ -457,13 +400,12 @@
@@ -457,13 +402,12 @@
}
a: (_|_){
// [eval]
Expand All @@ -1045,7 +1080,7 @@ diff old new
}
}
t8: (_|_){
@@ -477,19 +419,17 @@
@@ -477,19 +421,17 @@
// [eval]
c: (_|_){
// [eval]
Expand All @@ -1072,7 +1107,7 @@ diff old new
#x: (#struct){
y: (#struct){
z?: (#struct){
@@ -497,14 +437,25 @@
@@ -497,26 +439,41 @@
}
}
}
Expand All @@ -1084,6 +1119,10 @@ diff old new
- x2: (struct){
- name: (string){ "blah" }
- age2: (int){ 5 }
- }
- }
- }
- issue3491: (struct){
+ egs: (_|_){
+ // [eval]
+ x1: (_|_){
Expand All @@ -1103,9 +1142,27 @@ diff old new
+ // ./issue1830.cue:15:7
+ // ./issue1830.cue:17:4
+ }
+ }
+ }
+ }
+ issue3491: (_|_){
+ // [eval]
#Schema: (#struct){
field?: (#struct){
}
}
- a: (#struct){
+ a: (_|_){
+ // [eval]
field: (#struct){
}
- #Extra: (#struct){
+ #Extra: (_|_){
+ // [eval] issue3491.a.#Extra: field not allowed:
+ // ./issue3491.cue:8:5
}
}
}
b: (struct){
-- diff/todo/p2 --
ok.t1.c.0: closedness probably incorrect: #R defines elements as type "top",
which are not closed by definition. Probably does not matter for evaluation,
Expand Down Expand Up @@ -1629,6 +1686,22 @@ Result:
}
}
}
issue3491: (struct){
#Schema: (#struct){
field?: (#struct){
}
}
a: (#struct){
field: (#struct){
}
#Extra: (#struct){
}
}
b: (struct){
#Extra: (#struct){
}
}
}
}
-- out/compile --
--- in.cue
Expand Down Expand Up @@ -2044,3 +2117,18 @@ Result:
}
}
}
--- issue3491.cue
{
issue3491: {
#Schema: {
field?: {}
}
a: (〈0;#Schema〉 & {
field: {}
})
a: 〈0;b〉
b: {
#Extra: {}
}
}
}

0 comments on commit 9ba55dc

Please sign in to comment.