diff --git a/cue/testdata/benchmarks/issue1684.txtar b/cue/testdata/benchmarks/issue1684.txtar index d4ca402d928..56617cddb6c 100644 --- a/cue/testdata/benchmarks/issue1684.txtar +++ b/cue/testdata/benchmarks/issue1684.txtar @@ -63,14 +63,14 @@ nestedClosed: passing: { } -- out/evalalpha/stats -- Leaks: 2135 -Freed: 530 -Reused: 530 +Freed: 658 +Reused: 658 Allocs: 2135 Retain: 0 Unifications: 475 -Conjuncts: 4351 -Disjuncts: 790 +Conjuncts: 4799 +Disjuncts: 918 -- out/evalalpha -- (struct){ #Secret: (#struct){ @@ -144,8 +144,8 @@ diff old new -Reused: 1064282 -Allocs: 51 +Leaks: 2135 -+Freed: 530 -+Reused: 530 ++Freed: 658 ++Reused: 658 +Allocs: 2135 Retain: 0 @@ -153,8 +153,8 @@ diff old new -Conjuncts: 2480117 -Disjuncts: 1064333 +Unifications: 475 -+Conjuncts: 4351 -+Disjuncts: 790 ++Conjuncts: 4799 ++Disjuncts: 918 -- diff/-out/evalalpha<==>+out/eval -- diff old new --- old diff --git a/cue/testdata/comprehensions/issue837.txtar b/cue/testdata/comprehensions/issue837.txtar index a9bab46f324..93bffce4a19 100644 --- a/cue/testdata/comprehensions/issue837.txtar +++ b/cue/testdata/comprehensions/issue837.txtar @@ -75,10 +75,10 @@ Conjuncts: 563 Disjuncts: 30 -- out/evalalpha -- Errors: -#Configure.service.description.configed.labstr: undefined field: label: - ./in.cue:51:14 -#DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label: - ./in.cue:51:14 +#Configure.service.description.role: undefined field: role: + ./in.cue:40:19 +#DoDeploy.deployment.description.service.description.role: undefined field: role: + ./in.cue:40:19 #RelabelService.out.labstr: undefined field: label: ./in.cue:51:14 @@ -133,8 +133,8 @@ Result: } } role: (_|_){ - // [eval] #DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label: - // ./in.cue:51:14 + // [eval] #DoDeploy.deployment.description.service.description.role: undefined field: role: + // ./in.cue:40:19 } } } @@ -159,8 +159,8 @@ Result: } } role: (_|_){ - // [eval] #Configure.service.description.configed.labstr: undefined field: label: - // ./in.cue:51:14 + // [eval] #Configure.service.description.role: undefined field: role: + // ./in.cue:40:19 } } } @@ -202,19 +202,6 @@ Result: diff old new --- old +++ new -@@ -1,8 +1,8 @@ - Errors: --#Configure.service.description.role: undefined field: role: -- ./in.cue:40:19 --#DoDeploy.deployment.description.service.description.role: undefined field: role: -- ./in.cue:40:19 -+#Configure.service.description.configed.labstr: undefined field: label: -+ ./in.cue:51:14 -+#DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label: -+ ./in.cue:51:14 - #RelabelService.out.labstr: undefined field: label: - ./in.cue:51:14 - @@ -13,24 +13,10 @@ ref: (#struct){ kind: (string){ "deployment" } @@ -308,28 +295,6 @@ diff old new service: (_|_){ // [eval] description: (_|_){ -@@ -106,8 +57,8 @@ - } - } - role: (_|_){ -- // [eval] #DoDeploy.deployment.description.service.description.role: undefined field: role: -- // ./in.cue:40:19 -+ // [eval] #DoDeploy.deployment.description.service.description.configed.labstr: undefined field: label: -+ // ./in.cue:51:14 - } - } - } -@@ -132,8 +83,8 @@ - } - } - role: (_|_){ -- // [eval] #Configure.service.description.role: undefined field: role: -- // ./in.cue:40:19 -+ // [eval] #Configure.service.description.configed.labstr: undefined field: label: -+ // ./in.cue:51:14 - } - } - } @@ -141,9 +92,7 @@ #RelabelService: (_|_){ // [eval] diff --git a/cue/testdata/cycle/evaluate.txtar b/cue/testdata/cycle/evaluate.txtar index 04207707d82..8c8c5ed0e9d 100644 --- a/cue/testdata/cycle/evaluate.txtar +++ b/cue/testdata/cycle/evaluate.txtar @@ -128,12 +128,11 @@ Disjuncts: 192 -- out/evalalpha -- Errors: closeCycle.c: structural cycle +letCycleFail.t1.a.c: structural cycle printCycle.a.X: structural cycle structCycle.c: structural cycle letCycleOK.t2.a.X: structural cycle: ./in.cue:23:11 -letCycleFail.t1.a.X: structural cycle: - ./in.cue:33:11 disjunctionCycle.b: cannot use 1 (type int) as type list: ./in.cue:56:5 ./in.cue:56:9 @@ -186,8 +185,7 @@ Result: // [structural cycle] letCycleFail.t1.a.X: structural cycle } c: (_|_){ - // [structural cycle] letCycleFail.t1.a.X: structural cycle: - // ./in.cue:33:11 + // [structural cycle] letCycleFail.t1.a.c: structural cycle } } } @@ -350,7 +348,7 @@ Result: diff old new --- old +++ new -@@ -1,50 +1,49 @@ +@@ -1,50 +1,48 @@ Errors: -closeCycle.a: structural cycle -closeCycle.b.d: structural cycle @@ -359,19 +357,17 @@ diff old new - ./in.cue:105:12 - ./in.cue:106:6 - ./in.cue:107:5 --letCycleFail.t1.a.c: structural cycle ++closeCycle.c: structural cycle + letCycleFail.t1.a.c: structural cycle -structCycle.a: structural cycle -structCycle.b.d: structural cycle -disjunctionCycle.a: cannot use 1 (type int) as type list: - ./in.cue:56:5 - ./in.cue:56:9 -+closeCycle.c: structural cycle +printCycle.a.X: structural cycle +structCycle.c: structural cycle +letCycleOK.t2.a.X: structural cycle: + ./in.cue:23:11 -+letCycleFail.t1.a.X: structural cycle: -+ ./in.cue:33:11 disjunctionCycle.b: cannot use 1 (type int) as type list: ./in.cue:56:5 ./in.cue:56:9 @@ -428,16 +424,10 @@ diff old new } } } -@@ -59,20 +58,16 @@ - // [structural cycle] letCycleFail.t1.a.X: structural cycle - } - c: (_|_){ -- // [structural cycle] letCycleFail.t1.a.c: structural cycle -- } -- } -- } -- t2: (struct){ -- a: (struct){ +@@ -65,14 +63,9 @@ + } + t2: (struct){ + a: (struct){ - let X#4 = (struct){ - let X#4 = (_|_){ - // [structural cycle] letCycleFail.t2.a.X.X: structural cycle: @@ -446,20 +436,13 @@ diff old new - x: (struct){ - y: (string){ "" } - } -+ // [structural cycle] letCycleFail.t1.a.X: structural cycle: -+ // ./in.cue:33:11 -+ } -+ } -+ } -+ t2: (struct){ -+ a: (struct){ + let X#4 = (_|_){ + // [structural cycle] letCycleFail.t2.a.X: structural cycle: + // ./in.cue:43:6 } x: (struct){ y: (string){ "" } -@@ -88,17 +83,17 @@ +@@ -88,17 +81,17 @@ disjunctionCycle: (_|_){ // [eval] a: (_|_){ @@ -488,7 +471,7 @@ diff old new // ./in.cue:56:5 // ./in.cue:56:9 } -@@ -124,80 +119,77 @@ +@@ -124,80 +117,77 @@ } b: (struct){ } @@ -618,7 +601,7 @@ diff old new } } closeFail: (_|_){ -@@ -207,21 +199,22 @@ +@@ -207,21 +197,22 @@ } x: (_|_){ // [eval] diff --git a/cue/testdata/cycle/issue990.txtar b/cue/testdata/cycle/issue990.txtar index 5794b0d2d22..ee2465e446f 100644 --- a/cue/testdata/cycle/issue990.txtar +++ b/cue/testdata/cycle/issue990.txtar @@ -77,29 +77,20 @@ _test: { // Test out: #sub & {#p: _test.s1} --- diff/todo/p0 -- -out.subs.subs.#p: invalid structural cycle -This seems to be the result of incorrect handling of disjunctions. -- diff/todo/p3 -- Reordering -- out/evalalpha/stats -- -Leaks: 605 -Freed: 45 -Reused: 45 -Allocs: 605 +Leaks: 1834 +Freed: 197 +Reused: 197 +Allocs: 1834 Retain: 0 -Unifications: 175 -Conjuncts: 2668 -Disjuncts: 92 +Unifications: 243 +Conjuncts: 4474 +Disjuncts: 396 -- out/evalalpha -- -Errors: -out.subs: structural cycle: - ./in.cue:34:17 - -Result: -(_|_){ - // [structural cycle] +(struct){ #AC: (#struct){ k: (string){ "simple" } d: ~(#C) @@ -243,9 +234,88 @@ Result: k: (string){ "complex" } } } - out: (_|_){ - // [structural cycle] out.subs: structural cycle: - // ./in.cue:34:17 + out: (#struct){ + #p: (#struct){ + d: (#struct){ + n: (string){ "s1" } + r: (#struct){ + r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + r2: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "s2" } + r: (#struct){ + r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + r2: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "s3" } + r: (#struct){ + r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + } + } + k: (string){ "complex" } + } + } + } + } + k: (string){ "complex" } + } + } + } + } + k: (string){ "complex" } + } + dict: (#struct){ + r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + r2_r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + r2_r2_r1: (#struct){ + a: (#struct){ + d: (#struct){ + n: (string){ "c1" } + } + k: (string){ "simple" } + } + } + } + let subs#1multi = (〈3;#sub〉 & { + #p: 〈2;rd〉.a + }) } } -- diff/-out/evalalpha/stats<==>+out/eval/stats -- @@ -258,31 +328,24 @@ diff old new -Reused: 3213 -Allocs: 25 -Retain: 26 -+Leaks: 605 -+Freed: 45 -+Reused: 45 -+Allocs: 605 ++Leaks: 1834 ++Freed: 197 ++Reused: 197 ++Allocs: 1834 +Retain: 0 -Unifications: 2588 -Conjuncts: 12056 -Disjuncts: 3258 -+Unifications: 175 -+Conjuncts: 2668 -+Disjuncts: 92 ++Unifications: 243 ++Conjuncts: 4474 ++Disjuncts: 396 -- diff/-out/evalalpha<==>+out/eval -- diff old new --- old +++ new -@@ -1,31 +1,25 @@ --(struct){ -+Errors: -+out.subs: structural cycle: -+ ./in.cue:34:17 -+ -+Result: -+(_|_){ -+ // [structural cycle] +@@ -1,31 +1,19 @@ + (struct){ #AC: (#struct){ k: (string){ "simple" } - d: (#struct){ @@ -317,7 +380,7 @@ diff old new }) } } #S: (#struct){ -@@ -37,14 +31,7 @@ +@@ -37,14 +25,7 @@ n: (string){ string } } #sub: (#struct){ @@ -333,7 +396,7 @@ diff old new dict: (#struct){ } let subs#1multi = (〈3;#sub〉 & { -@@ -53,195 +40,116 @@ +@@ -53,190 +34,190 @@ } _test: (struct){ c1: (#struct){ @@ -475,10 +538,60 @@ diff old new - } - } - } -- } -- } -- out: (#struct){ -- #p: (#struct){ ++ d: (#struct){ ++ n: (string){ "s1" } ++ r: (#struct){ ++ r1: (#struct){ ++ a: (#struct){ ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } ++ } ++ } ++ r2: (#struct){ ++ a: (#struct){ ++ d: (#struct){ ++ n: (string){ "s2" } ++ r: (#struct){ ++ r1: (#struct){ ++ a: (#struct){ ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } ++ } ++ } ++ r2: (#struct){ ++ a: (#struct){ ++ d: (#struct){ ++ n: (string){ "s3" } ++ r: (#struct){ ++ r1: (#struct){ ++ a: (#struct){ ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } ++ } ++ } ++ } ++ } ++ k: (string){ "complex" } ++ } ++ } ++ } ++ } ++ k: (string){ "complex" } ++ } ++ } ++ } ++ } ++ k: (string){ "complex" } + } + } + out: (#struct){ + #p: (#struct){ - k: (string){ "complex" } - d: (#struct){ - n: (string){ "s1" } @@ -529,36 +642,6 @@ diff old new - } - } - } -- } -- dict: (#struct){ -- r1: (#struct){ -- a: (#struct){ -- k: (string){ "simple" } -- d: (#struct){ -- n: (string){ "c1" } -- } -- } -- } -- r2_r1: (#struct){ -- a: (#struct){ -- k: (string){ "simple" } -- d: (#struct){ -- n: (string){ "c1" } -- } -- } -- } -- r2_r2_r1: (#struct){ -- a: (#struct){ -- k: (string){ "simple" } -- d: (#struct){ -- n: (string){ "c1" } -- } -- } -- } -- } -- let subs#1multi = (〈3;#sub〉 & { -- #p: 〈2;rd〉.a -- }) + d: (#struct){ + n: (string){ "s1" } + r: (#struct){ @@ -609,13 +692,45 @@ diff old new + } + } + k: (string){ "complex" } -+ } -+ } -+ out: (_|_){ -+ // [structural cycle] out.subs: structural cycle: -+ // ./in.cue:34:17 - } - } + } + dict: (#struct){ + r1: (#struct){ + a: (#struct){ +- k: (string){ "simple" } +- d: (#struct){ +- n: (string){ "c1" } +- } ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } + } + } + r2_r1: (#struct){ + a: (#struct){ +- k: (string){ "simple" } +- d: (#struct){ +- n: (string){ "c1" } +- } ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } + } + } + r2_r2_r1: (#struct){ + a: (#struct){ +- k: (string){ "simple" } +- d: (#struct){ +- n: (string){ "c1" } +- } ++ d: (#struct){ ++ n: (string){ "c1" } ++ } ++ k: (string){ "simple" } + } + } + } -- out/eval/stats -- Leaks: 6 Freed: 3232 diff --git a/cue/testdata/eval/let.txtar b/cue/testdata/eval/let.txtar index 3a3cb2a2f4a..eb6b323ddce 100644 --- a/cue/testdata/eval/let.txtar +++ b/cue/testdata/eval/let.txtar @@ -330,13 +330,13 @@ Result: } "0": (struct){ let X#1Fmulti = 〈1;x〉 - "2": (int){ 2 } "1": (int){ 1 } + "2": (int){ 2 } } "1": (struct){ let X#1Fmulti = 〈1;x〉 - "2": (int){ 2 } "1": (int){ 1 } + "2": (int){ 2 } } } keepDescending: (struct){ @@ -502,24 +502,6 @@ diff old new } } nestedFor: (struct){ -@@ -190,13 +159,13 @@ - } - "0": (struct){ - let X#1Fmulti = 〈1;x〉 -- "1": (int){ 1 } -- "2": (int){ 2 } -+ "2": (int){ 2 } -+ "1": (int){ 1 } - } - "1": (struct){ - let X#1Fmulti = 〈1;x〉 -- "1": (int){ 1 } -- "2": (int){ 2 } -+ "2": (int){ 2 } -+ "1": (int){ 1 } - } - } - keepDescending: (struct){ @@ -234,8 +203,8 @@ b: (string){ "e" } } diff --git a/cue/testdata/eval/letjoin.txtar b/cue/testdata/eval/letjoin.txtar index ea88d199a58..782a97200fc 100644 --- a/cue/testdata/eval/letjoin.txtar +++ b/cue/testdata/eval/letjoin.txtar @@ -138,8 +138,8 @@ Reused: 19 Allocs: 203 Retain: 0 -Unifications: 186 -Conjuncts: 1067 +Unifications: 178 +Conjuncts: 1191 Disjuncts: 36 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- diff old new @@ -160,8 +160,8 @@ diff old new -Unifications: 167 -Conjuncts: 486 -Disjuncts: 325 -+Unifications: 186 -+Conjuncts: 1067 ++Unifications: 178 ++Conjuncts: 1191 +Disjuncts: 36 -- out/eval/stats -- Leaks: 24 diff --git a/cue/testdata/eval/notify.txtar b/cue/testdata/eval/notify.txtar index 8c754ce9fe6..eec32037c16 100644 --- a/cue/testdata/eval/notify.txtar +++ b/cue/testdata/eval/notify.txtar @@ -1596,14 +1596,14 @@ Result: } } -- out/evalalpha/stats -- -Leaks: 2156 +Leaks: 2249 Freed: 266 Reused: 265 -Allocs: 2157 +Allocs: 2250 Retain: 0 -Unifications: 750 -Conjuncts: 12910 +Unifications: 760 +Conjuncts: 13284 Disjuncts: 908 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- diff old new @@ -1615,17 +1615,17 @@ diff old new -Reused: 85 -Allocs: 46 -Retain: 5 -+Leaks: 2156 ++Leaks: 2249 +Freed: 266 +Reused: 265 -+Allocs: 2157 ++Allocs: 2250 +Retain: 0 -Unifications: 48 -Conjuncts: 150 -Disjuncts: 111 -+Unifications: 750 -+Conjuncts: 12910 ++Unifications: 760 ++Conjuncts: 13284 +Disjuncts: 908 -- out/eval/stats -- Leaks: 34 diff --git a/internal/core/adt/cycle.go b/internal/core/adt/cycle.go index 52d29a78ab3..7be37635ff7 100644 --- a/internal/core/adt/cycle.go +++ b/internal/core/adt/cycle.go @@ -721,7 +721,7 @@ func (n *nodeContext) markCyclicPathV3(arc *Vertex, env *Environment, x Resolver n.hasAnyCyclicConjunct = true - if !n.hasNonCyclic && env != nil { + if !n.hasNonCyclic && !n.hasNonCycle && env != nil { // TODO: investigate if we can get rid of cyclicConjuncts in the new // evaluator. v := Conjunct{env, x, ci} diff --git a/internal/core/adt/expr.go b/internal/core/adt/expr.go index ff6a68319e2..cf25b71e7ed 100644 --- a/internal/core/adt/expr.go +++ b/internal/core/adt/expr.go @@ -999,7 +999,6 @@ func (x *LetReference) resolve(ctx *OpContext, state combinedFlags) *Vertex { // nc.hasNonCycle = true // Allow a first cycle to be skipped. nc.free() - n.unify(ctx, allKnown, finalize) } else { nc := n.getNodeContext(ctx, 0) nc.hasNonCycle = true // Allow a first cycle to be skipped.