From 06f41bca90483f338fd16fc9c6335f5c637c0e6f Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Mon, 23 Dec 2024 12:23:15 +0100 Subject: [PATCH] internal/core/adt: add tests for 3590 and 3591 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue is a regression introduced in https://cuelang.org/cl/1199752 Issue #3590 Issue #3591 Signed-off-by: Marcel van Lohuizen Change-Id: I1e2a9be08a7957b72c4904856f68af8f9efc3c45 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206278 Reviewed-by: Daniel Martí Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo --- cue/testdata/eval/letjoin.txtar | 650 +++++++++++++++++++++++++++++++- 1 file changed, 639 insertions(+), 11 deletions(-) diff --git a/cue/testdata/eval/letjoin.txtar b/cue/testdata/eval/letjoin.txtar index 5726a893216..e9b09178253 100644 --- a/cue/testdata/eval/letjoin.txtar +++ b/cue/testdata/eval/letjoin.txtar @@ -43,18 +43,152 @@ t2: { xy: x1 & x2 } +-- issue3590.cue -- +issue3590: reduced: { + result: [_]: [string]: string + + _input: { + A: p: "A" + B: p: "B" + } + + for _, v in _input { + let Var1 = v.p + + // Second let variable required here; just using Var1 with Items not + // sufficient + let Var2 = Var1 + + let Items = { + item: Var2 + } + + result: "conflicting-\(v.p)": Items + } +} +issue3590: full: { + #Result: [_]: {[string]: string} + + result: #Result + + #Input: { + p: "A" | "B" + } + + _input: [Parm=_]: #Input & { + p: Parm + } + + _input: { + A: {} + B: {} + } + + for _, v in _input { + let Var1 = v.p + let Var2 = Var1 + + let Items = { + "item": Var2 + } + + result: "conflicting-\(v.p)": Items + } +} +// Issue #3591 is related +issue3591: missing: { + #Result: [_]: {[string]: string} + + result: #Result + + #Input: { + p: "A" | "B" + } + + _input: [Parm=_]: #Input & { + p: Parm + } + + _input: { + A: {} + B: {} + } + + for _, v in _input { + let Var1 = v.p + let Var2 = Var1 + + let Items = { + "item": { + key1: Var2 + } + } + + result: "missing-items-\(v.p)": { + for s, attr in Items { + if attr.key1 != _|_ {(s): attr.key1} + } + } + } +} +-- out/evalalpha/stats -- +Leaks: 182 +Freed: 18 +Reused: 17 +Allocs: 183 +Retain: 0 + +Unifications: 170 +Conjuncts: 996 +Disjuncts: 30 +-- diff/-out/evalalpha/stats<==>+out/eval/stats -- +diff old new +--- old ++++ new +@@ -1,9 +1,9 @@ +-Leaks: 19 +-Freed: 202 +-Reused: 187 +-Allocs: 34 +-Retain: 141 ++Leaks: 182 ++Freed: 18 ++Reused: 17 ++Allocs: 183 ++Retain: 0 + +-Unifications: 157 +-Conjuncts: 447 +-Disjuncts: 297 ++Unifications: 170 ++Conjuncts: 996 ++Disjuncts: 30 -- out/eval/stats -- -Leaks: 8 -Freed: 65 -Reused: 60 -Allocs: 13 -Retain: 8 +Leaks: 19 +Freed: 202 +Reused: 187 +Allocs: 34 +Retain: 141 -Unifications: 73 -Conjuncts: 123 -Disjuncts: 69 +Unifications: 157 +Conjuncts: 447 +Disjuncts: 297 -- out/evalalpha -- -(struct){ +Errors: +issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:33:6 +issue3590.full.result."conflicting-B".item: conflicting values "B" and "A": + ./issue3590.cue:33:6 +issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:5:9 + ./issue3590.cue:6:9 +issue3590.reduced.result."conflicting-B".item: conflicting values "B" and "A": + ./issue3590.cue:5:9 + ./issue3590.cue:6:9 + +Result: +(_|_){ + // [eval] t1: (struct){ x: (struct){ a: (int){ int } @@ -145,12 +279,151 @@ Disjuncts: 69 } } } + issue3590: (_|_){ + // [eval] + reduced: (_|_){ + // [eval] + result: (_|_){ + // [eval] + "conflicting-A": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 + } + } + "conflicting-B": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.reduced.result."conflicting-B".item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 + } + } + } + _input: (struct){ + A: (struct){ + p: (string){ "A" } + } + B: (struct){ + p: (string){ "B" } + } + } + let Var1#3multi = 〈1;v〉.p + let Var2#4multi = 〈0;let Var1#3〉 + let Items#5 = (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.reduced.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 + } + } + } + full: (_|_){ + // [eval] + #Result: (#struct){ + } + result: (_|_){ + // [eval] + "conflicting-A": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 + } + } + "conflicting-B": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.full.result."conflicting-B".item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 + } + } + } + #Input: (#struct){ + p: (string){ |((string){ "A" }, (string){ "B" }) } + } + _input: (struct){ + A: (#struct){ + p: (string){ "A" } + } + B: (#struct){ + p: (string){ "B" } + } + } + let Var1#6multi = 〈1;v〉.p + let Var2#7multi = 〈0;let Var1#6〉 + let Items#8 = (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.full.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 + } + } + } + } + issue3591: (struct){ + missing: (_|_){ + // [incomplete] issue3591.missing.Items.item.key1: cyclic reference to field item: + // ./issue3590.cue:71:2 + #Result: (#struct){ + } + result: (#struct){ + "missing-items-A": (#struct){ + } + "missing-items-B": (#struct){ + } + } + #Input: (#struct){ + p: (string){ |((string){ "A" }, (string){ "B" }) } + } + _input: (struct){ + A: (#struct){ + p: (string){ "A" } + } + B: (#struct){ + p: (string){ "B" } + } + } + let Var1#9multi = 〈1;v〉.p + let Var2#Amulti = 〈0;let Var1#9〉 + let Items#B = (struct){ + } + } + } } -- diff/-out/evalalpha<==>+out/eval -- diff old new --- old +++ new -@@ -57,23 +57,19 @@ +@@ -1,19 +1,14 @@ + Errors: + issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:33:6 +- ./issue3590.cue:41:2 +- ./issue3590.cue:42:14 +- ./issue3590.cue:43:14 +- ./issue3590.cue:46:12 +- ./issue3590.cue:49:33 ++issue3590.full.result."conflicting-B".item: conflicting values "B" and "A": ++ ./issue3590.cue:33:6 + issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:5:9 + ./issue3590.cue:6:9 +- ./issue3590.cue:9:2 +- ./issue3590.cue:10:14 +- ./issue3590.cue:14:14 +- ./issue3590.cue:17:10 +- ./issue3590.cue:20:33 ++issue3590.reduced.result."conflicting-B".item: conflicting values "B" and "A": ++ ./issue3590.cue:5:9 ++ ./issue3590.cue:6:9 + + Result: + (_|_){ +@@ -76,23 +71,19 @@ } y: (struct){ let X#2 = (struct){ @@ -187,10 +460,130 @@ diff old new c: (int){ 1 } } v: (int){ 1 } +@@ -124,15 +115,15 @@ + // [eval] issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 +- // ./issue3590.cue:9:2 +- // ./issue3590.cue:10:14 +- // ./issue3590.cue:14:14 +- // ./issue3590.cue:17:10 +- // ./issue3590.cue:20:33 +- } +- } +- "conflicting-B": (struct){ +- item: (string){ "B" } ++ } ++ } ++ "conflicting-B": (_|_){ ++ // [eval] ++ item: (_|_){ ++ // [eval] issue3590.reduced.result."conflicting-B".item: conflicting values "B" and "A": ++ // ./issue3590.cue:5:9 ++ // ./issue3590.cue:6:9 ++ } + } + } + _input: (struct){ +@@ -151,10 +142,6 @@ + // [eval] issue3590.reduced.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 +- // ./issue3590.cue:9:2 +- // ./issue3590.cue:10:14 +- // ./issue3590.cue:14:14 +- // ./issue3590.cue:17:10 + } + } + } +@@ -169,15 +156,14 @@ + item: (_|_){ + // [eval] issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 +- // ./issue3590.cue:41:2 +- // ./issue3590.cue:42:14 +- // ./issue3590.cue:43:14 +- // ./issue3590.cue:46:12 +- // ./issue3590.cue:49:33 +- } +- } +- "conflicting-B": (#struct){ +- item: (string){ "B" } ++ } ++ } ++ "conflicting-B": (_|_){ ++ // [eval] ++ item: (_|_){ ++ // [eval] issue3590.full.result."conflicting-B".item: conflicting values "B" and "A": ++ // ./issue3590.cue:33:6 ++ } + } + } + #Input: (#struct){ +@@ -198,16 +184,14 @@ + item: (_|_){ + // [eval] issue3590.full.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 +- // ./issue3590.cue:41:2 +- // ./issue3590.cue:42:14 +- // ./issue3590.cue:43:14 +- // ./issue3590.cue:46:12 + } + } + } + } + issue3591: (struct){ +- missing: (struct){ ++ missing: (_|_){ ++ // [incomplete] issue3591.missing.Items.item.key1: cyclic reference to field item: ++ // ./issue3590.cue:71:2 + #Result: (#struct){ + } + result: (#struct){ +@@ -229,19 +213,7 @@ + } + let Var1#9multi = 〈1;v〉.p + let Var2#Amulti = 〈0;let Var1#9〉 +- let Items#B = (_|_){ +- // [eval] +- item: (_|_){ +- // [eval] +- key1: (_|_){ +- // [eval] issue3591.missing.Items.item.key1: conflicting values "B" and "A": +- // ./issue3590.cue:63:6 +- // ./issue3590.cue:71:2 +- // ./issue3590.cue:72:14 +- // ./issue3590.cue:73:14 +- // ./issue3590.cue:77:11 +- } +- } ++ let Items#B = (struct){ + } + } + } -- diff/todo/p4 -- Reduce conjunct group size. Semantically correct, though. -- out/eval -- -(struct){ +Errors: +issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:33:6 + ./issue3590.cue:41:2 + ./issue3590.cue:42:14 + ./issue3590.cue:43:14 + ./issue3590.cue:46:12 + ./issue3590.cue:49:33 +issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + ./issue3590.cue:5:9 + ./issue3590.cue:6:9 + ./issue3590.cue:9:2 + ./issue3590.cue:10:14 + ./issue3590.cue:14:14 + ./issue3590.cue:17:10 + ./issue3590.cue:20:33 + +Result: +(_|_){ + // [eval] t1: (struct){ x: (struct){ a: (int){ int } @@ -285,6 +678,139 @@ Reduce conjunct group size. Semantically correct, though. } } } + issue3590: (_|_){ + // [eval] + reduced: (_|_){ + // [eval] + result: (_|_){ + // [eval] + "conflicting-A": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.reduced.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 + // ./issue3590.cue:9:2 + // ./issue3590.cue:10:14 + // ./issue3590.cue:14:14 + // ./issue3590.cue:17:10 + // ./issue3590.cue:20:33 + } + } + "conflicting-B": (struct){ + item: (string){ "B" } + } + } + _input: (struct){ + A: (struct){ + p: (string){ "A" } + } + B: (struct){ + p: (string){ "B" } + } + } + let Var1#3multi = 〈1;v〉.p + let Var2#4multi = 〈0;let Var1#3〉 + let Items#5 = (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.reduced.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:5:9 + // ./issue3590.cue:6:9 + // ./issue3590.cue:9:2 + // ./issue3590.cue:10:14 + // ./issue3590.cue:14:14 + // ./issue3590.cue:17:10 + } + } + } + full: (_|_){ + // [eval] + #Result: (#struct){ + } + result: (_|_){ + // [eval] + "conflicting-A": (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.full.result."conflicting-A".item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 + // ./issue3590.cue:41:2 + // ./issue3590.cue:42:14 + // ./issue3590.cue:43:14 + // ./issue3590.cue:46:12 + // ./issue3590.cue:49:33 + } + } + "conflicting-B": (#struct){ + item: (string){ "B" } + } + } + #Input: (#struct){ + p: (string){ |((string){ "A" }, (string){ "B" }) } + } + _input: (struct){ + A: (#struct){ + p: (string){ "A" } + } + B: (#struct){ + p: (string){ "B" } + } + } + let Var1#6multi = 〈1;v〉.p + let Var2#7multi = 〈0;let Var1#6〉 + let Items#8 = (_|_){ + // [eval] + item: (_|_){ + // [eval] issue3590.full.Items.item: conflicting values "B" and "A": + // ./issue3590.cue:33:6 + // ./issue3590.cue:41:2 + // ./issue3590.cue:42:14 + // ./issue3590.cue:43:14 + // ./issue3590.cue:46:12 + } + } + } + } + issue3591: (struct){ + missing: (struct){ + #Result: (#struct){ + } + result: (#struct){ + "missing-items-A": (#struct){ + } + "missing-items-B": (#struct){ + } + } + #Input: (#struct){ + p: (string){ |((string){ "A" }, (string){ "B" }) } + } + _input: (struct){ + A: (#struct){ + p: (string){ "A" } + } + B: (#struct){ + p: (string){ "B" } + } + } + let Var1#9multi = 〈1;v〉.p + let Var2#Amulti = 〈0;let Var1#9〉 + let Items#B = (_|_){ + // [eval] + item: (_|_){ + // [eval] + key1: (_|_){ + // [eval] issue3591.missing.Items.item.key1: conflicting values "B" and "A": + // ./issue3590.cue:63:6 + // ./issue3590.cue:71:2 + // ./issue3590.cue:72:14 + // ./issue3590.cue:73:14 + // ./issue3590.cue:77:11 + } + } + } + } + } } -- out/compile -- --- in.cue @@ -336,3 +862,105 @@ Reduce conjunct group size. Semantically correct, though. xy: (〈0;x1〉 & 〈0;x2〉) } } +--- issue3590.cue +{ + issue3590: { + reduced: { + result: { + [_]: { + [string]: string + } + } + _input: { + A: { + p: "A" + } + B: { + p: "B" + } + } + for _, v in 〈0;_input〉 { + let Var1#3multi = 〈1;v〉.p + let Var2#4multi = 〈0;let Var1#3〉 + let Items#5 = { + item: 〈1;let Var2#4〉 + } + result: { + "conflicting-\(〈2;v〉.p)": 〈1;let Items#5〉 + } + } + } + } + issue3590: { + full: { + #Result: { + [_]: { + [string]: string + } + } + result: 〈0;#Result〉 + #Input: { + p: ("A"|"B") + } + _input: { + [_]: (〈1;#Input〉 & { + p: 〈1;-〉 + }) + } + _input: { + A: {} + B: {} + } + for _, v in 〈0;_input〉 { + let Var1#6multi = 〈1;v〉.p + let Var2#7multi = 〈0;let Var1#6〉 + let Items#8 = { + item: 〈1;let Var2#7〉 + } + result: { + "conflicting-\(〈2;v〉.p)": 〈1;let Items#8〉 + } + } + } + } + issue3591: { + missing: { + #Result: { + [_]: { + [string]: string + } + } + result: 〈0;#Result〉 + #Input: { + p: ("A"|"B") + } + _input: { + [_]: (〈1;#Input〉 & { + p: 〈1;-〉 + }) + } + _input: { + A: {} + B: {} + } + for _, v in 〈0;_input〉 { + let Var1#9multi = 〈1;v〉.p + let Var2#Amulti = 〈0;let Var1#9〉 + let Items#B = { + item: { + key1: 〈2;let Var2#A〉 + } + } + result: { + "missing-items-\(〈2;v〉.p)": { + for s, attr in 〈2;let Items#B〉 { + if (〈1;attr〉.key1 != _|_(explicit error (_|_ literal) in source)) { + 〈2;s〉: 〈2;attr〉.key1 + } + } + } + } + } + } + } +}