From dfe3ae033d26f79649d69c9dee6cc89ff7599c3d Mon Sep 17 00:00:00 2001 From: Marcel van Lohuizen Date: Thu, 9 Jan 2025 16:32:53 +0100 Subject: [PATCH] internal/core/validate: add test for issue 3651 Issue #3651 Signed-off-by: Marcel van Lohuizen Change-Id: I0f2755389bc954828dbc11d4dd53fd4b5eb72c17 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206949 Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo Reviewed-by: Roger Peppe --- cue/testdata/cycle/builtins.txtar | 109 ++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 22 deletions(-) diff --git a/cue/testdata/cycle/builtins.txtar b/cue/testdata/cycle/builtins.txtar index e93e76b480d..91a273ab990 100644 --- a/cue/testdata/cycle/builtins.txtar +++ b/cue/testdata/cycle/builtins.txtar @@ -126,50 +126,57 @@ issue3443: { fail: #S: matchN(1, [{n: #S}]) & {n: n: n: _} } } +issue3633: final: { + // With nested matchNs as below, the schema will become an incomplete error + // as a value of the root vertex. Make sure this edge case is properly + // handled. + data: {} & #s + #s: matchN(1, [matchN(1, [{a!: _}])]) +} -- todo/p1 -- issue3443.noCycle: fix hang -- out/evalalpha/stats -- -Leaks: 193 +Leaks: 211 Freed: 17 Reused: 17 -Allocs: 193 +Allocs: 211 Retain: 0 -Unifications: 167 -Conjuncts: 657 +Unifications: 183 +Conjuncts: 696 Disjuncts: 28 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- diff old new --- old +++ new @@ -1,9 +1,9 @@ --Leaks: 12 --Freed: 235 --Reused: 218 +-Leaks: 14 +-Freed: 249 +-Reused: 234 -Allocs: 29 --Retain: 65 -+Leaks: 193 +-Retain: 70 ++Leaks: 211 +Freed: 17 +Reused: 17 -+Allocs: 193 ++Allocs: 211 +Retain: 0 --Unifications: 211 --Conjuncts: 389 --Disjuncts: 290 -+Unifications: 167 -+Conjuncts: 657 +-Unifications: 227 +-Conjuncts: 413 +-Disjuncts: 309 ++Unifications: 183 ++Conjuncts: 696 +Disjuncts: 28 -- out/eval/stats -- -Leaks: 12 -Freed: 235 -Reused: 218 +Leaks: 14 +Freed: 249 +Reused: 234 Allocs: 29 -Retain: 65 +Retain: 70 -Unifications: 211 -Conjuncts: 389 -Disjuncts: 290 +Unifications: 227 +Conjuncts: 413 +Disjuncts: 309 -- out/evalalpha -- Errors: issue3443.matchIf.#S: cannot call non-function matchIf (type struct): @@ -350,6 +357,20 @@ Result: } } } + issue3633: (struct){ + final: (struct){ + data: (#struct){ + } + #s: (_){ matchN(1, (#list){ + 0: (_|_){// &[matchN(1, [ + // { + // a!: _ + // }, + // ])] + } + }) } + } + } } -- diff/-out/evalalpha<==>+out/eval -- diff old new @@ -476,6 +497,24 @@ diff old new n: (struct){ n: (_){ _ } } +@@ -167,14 +179,14 @@ + } + issue3633: (struct){ + final: (struct){ +- data: (struct){ ++ data: (#struct){ + } + #s: (_){ matchN(1, (#list){ +- 0: (_|_){// matchN(1, [ ++ 0: (_|_){// &[matchN(1, [ + // { + // a!: _ + // }, +- // ]) ++ // ])] + } + }) } + } -- diff/todo/p2 -- issue3443: Sort out differences in reporting of cycles. -- out/eval -- @@ -646,6 +685,20 @@ Result: } } } + issue3633: (struct){ + final: (struct){ + data: (struct){ + } + #s: (_){ matchN(1, (#list){ + 0: (_|_){// matchN(1, [ + // { + // a!: _ + // }, + // ]) + } + }) } + } + } } -- out/compile -- --- in.cue @@ -786,4 +839,16 @@ Result: } } } + issue3633: { + final: { + data: ({} & 〈0;#s〉) + #s: matchN(1, [ + matchN(1, [ + { + a!: _ + }, + ]), + ]) + } + } }