From 9ba55dc81ed2113c965c7a4c0e399b86fc105221 Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Thu, 10 Oct 2024 18:47:53 +0200 Subject: [PATCH] internal/core/adt: add tests for issue 3491 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To be immediately followed with fix. Issue #3491 Signed-off-by: Marcel van Lohuizen Change-Id: I86d2bfaa20600956bd3118fce07f71d1c4bff9f5 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202460 Unity-Result: CUE porcuepine Reviewed-by: Daniel Martí TryBot-Result: CUEcueckoo --- cue/testdata/definitions/fields.txtar | 140 +++++++++++++++++++++----- 1 file changed, 114 insertions(+), 26 deletions(-) diff --git a/cue/testdata/definitions/fields.txtar b/cue/testdata/definitions/fields.txtar index a9735845c89..a560fea87f5 100644 --- a/cue/testdata/definitions/fields.txtar +++ b/cue/testdata/definitions/fields.txtar @@ -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: @@ -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: (_|_){ @@ -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 @@ -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){ @@ -773,7 +808,7 @@ diff old new b: (int){ int } } } -@@ -72,7 +49,7 @@ +@@ -72,7 +51,7 @@ } t2: (struct){ #A: (_){ _ } @@ -782,7 +817,7 @@ diff old new f: (string){ "hi" } } } -@@ -102,11 +79,11 @@ +@@ -102,11 +81,11 @@ } } W: (#struct){ @@ -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: @@ -810,7 +845,7 @@ diff old new // ./in.cue:41:5 } } -@@ -156,16 +130,7 @@ +@@ -156,16 +132,7 @@ } } t8: (struct){ @@ -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){ @@ -837,7 +872,7 @@ diff old new b: (int){ int } } } -@@ -188,7 +153,7 @@ +@@ -188,7 +155,7 @@ } t10: (struct){ #A: (_){ _ } @@ -846,7 +881,7 @@ diff old new f: (string){ "hi" } } } -@@ -218,11 +183,11 @@ +@@ -218,11 +185,11 @@ } } W: (#struct){ @@ -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: @@ -874,7 +909,7 @@ diff old new // ./in.cue:112:5 } } -@@ -263,13 +225,12 @@ +@@ -263,13 +227,12 @@ } a: (_|_){ // [eval] @@ -889,7 +924,7 @@ diff old new } } t2: (_|_){ -@@ -283,14 +244,11 @@ +@@ -283,14 +246,11 @@ // [eval] c: (_|_){ // [eval] @@ -905,7 +940,7 @@ diff old new } } } -@@ -304,7 +262,6 @@ +@@ -304,7 +264,6 @@ // [eval] c: (_|_){ // [eval] err.t3.p1.a.c: field not allowed: @@ -913,7 +948,7 @@ diff old new // ./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: @@ -922,7 +957,7 @@ diff old new // ./in.cue:148:8 } } -@@ -336,54 +291,47 @@ +@@ -336,54 +293,47 @@ // [eval] b: (_|_){ // [eval] @@ -1010,7 +1045,7 @@ diff old new } } } -@@ -433,17 +381,12 @@ +@@ -433,17 +383,12 @@ // [eval] e: (_|_){ // [eval] @@ -1030,7 +1065,7 @@ diff old new } } } -@@ -457,13 +400,12 @@ +@@ -457,13 +402,12 @@ } a: (_|_){ // [eval] @@ -1045,7 +1080,7 @@ diff old new } } t8: (_|_){ -@@ -477,19 +419,17 @@ +@@ -477,19 +421,17 @@ // [eval] c: (_|_){ // [eval] @@ -1072,7 +1107,7 @@ diff old new #x: (#struct){ y: (#struct){ z?: (#struct){ -@@ -497,14 +437,25 @@ +@@ -497,26 +439,41 @@ } } } @@ -1084,6 +1119,10 @@ diff old new - x2: (struct){ - name: (string){ "blah" } - age2: (int){ 5 } +- } +- } +- } +- issue3491: (struct){ + egs: (_|_){ + // [eval] + x1: (_|_){ @@ -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, @@ -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 @@ -2044,3 +2117,18 @@ Result: } } } +--- issue3491.cue +{ + issue3491: { + #Schema: { + field?: {} + } + a: (〈0;#Schema〉 & { + field: {} + }) + a: 〈0;b〉 + b: { + #Extra: {} + } + } +}