this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: fix COMP counter issue

When reporting a cycle error in a comprehension,
insertArcCC would not return a closeContext,
which would disrupt the reference counting
mechanism. As reporting the error is optional
(see TODO) at that point, we solve this by just
disabling the code for now.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I67eaffea272bf74b6952257328b8b3cea320b29e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199773
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Matthew Sackman <matthew@cue.works>

+35 -41
+10 -10
cue/testdata/cycle/chain.txtar
··· 208 208 d: #Depth & {#in: tree} 209 209 } 210 210 -- out/evalalpha/stats -- 211 - Leaks: 19985 211 + Leaks: 19997 212 212 Freed: 1462 213 213 Reused: 1461 214 - Allocs: 19986 214 + Allocs: 19998 215 215 Retain: 0 216 216 217 - Unifications: 7496 218 - Conjuncts: 107414 219 - Disjuncts: 13651 217 + Unifications: 7504 218 + Conjuncts: 107530 219 + Disjuncts: 13655 220 220 -- out/evalalpha -- 221 221 Errors: 222 222 issue2052.t1.#Depth: adding field #basic not allowed as field set was already referenced: ··· 725 725 -Reused: 1801 726 726 -Allocs: 84 727 727 -Retain: 185 728 - +Leaks: 19985 728 + +Leaks: 19997 729 729 +Freed: 1462 730 730 +Reused: 1461 731 - +Allocs: 19986 731 + +Allocs: 19998 732 732 +Retain: 0 733 733 734 734 -Unifications: 800 735 735 -Conjuncts: 3175 736 736 -Disjuncts: 1974 737 - +Unifications: 7496 738 - +Conjuncts: 107414 739 - +Disjuncts: 13651 737 + +Unifications: 7504 738 + +Conjuncts: 107530 739 + +Disjuncts: 13655 740 740 -- diff/-out/evalalpha<==>+out/eval -- 741 741 diff old new 742 742 --- old
+2 -10
cue/testdata/cycle/disjunction.txtar
··· 186 186 issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"): 187 187 ./issue3042.cue:4:8 188 188 ./issue3042.cue:10:12 189 - issue3042.data.secret.infra.name: cyclic reference to field name: 190 - ./issue3042.cue:5:22 191 189 issue3042.data.secret: field not allowed: 192 190 ./issue3042.cue:5:57 193 191 ./issue3042.cue:8:3 ··· 307 305 // issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"): 308 306 // ./issue3042.cue:4:8 309 307 // ./issue3042.cue:10:12 310 - // issue3042.data.secret.infra.name: cyclic reference to field name: 311 - // ./issue3042.cue:5:22 312 308 // issue3042.data.secret: field not allowed: 313 309 // ./issue3042.cue:5:57 314 310 // ./issue3042.cue:8:3 ··· 328 324 diff old new 329 325 --- old 330 326 +++ new 331 - @@ -1,9 +1,62 @@ 327 + @@ -1,9 +1,60 @@ 332 328 Errors: 333 329 cycle.a: structural cycle 334 330 +issue3042.data: conflicting values [...#nesting] and {secret:{infra:[{name:"bar1"}]}} (mismatched types list and struct): ··· 373 369 +issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"): 374 370 + ./issue3042.cue:4:8 375 371 + ./issue3042.cue:10:12 376 - +issue3042.data.secret.infra.name: cyclic reference to field name: 377 - + ./issue3042.cue:5:22 378 372 +issue3042.data.secret: field not allowed: 379 373 + ./issue3042.cue:5:57 380 374 + ./issue3042.cue:8:3 ··· 392 386 cycle: (_|_){ 393 387 // [structural cycle] 394 388 a: (_|_){ 395 - @@ -58,22 +111,72 @@ 389 + @@ -58,22 +109,70 @@ 396 390 x: (#list){ 397 391 } 398 392 } ··· 458 452 + // issue3042.data.secret.infra.0.name: invalid value "bar1" (out of bound =~"^foo"): 459 453 + // ./issue3042.cue:4:8 460 454 + // ./issue3042.cue:10:12 461 - + // issue3042.data.secret.infra.name: cyclic reference to field name: 462 - + // ./issue3042.cue:5:22 463 455 + // issue3042.data.secret: field not allowed: 464 456 + // ./issue3042.cue:5:57 465 457 + // ./issue3042.cue:8:3
+14 -12
cue/testdata/cycle/freeze.txtar
··· 153 153 t1: (struct){ 154 154 ok: (struct){ 155 155 p0: (_|_){ 156 - // [incomplete] comprehension.t1.ok.p0.x.z: cyclic reference to field z: 156 + // [incomplete] comprehension.t1.ok.p0.x.z.a: cyclic reference to field z: 157 157 // ./comprehension.cue:9:3 158 158 // comprehension.t1.ok.p0.x.z.a: cyclic reference to field z: 159 159 // ./comprehension.cue:12:3 ··· 163 163 } 164 164 } 165 165 p1: (_|_){ 166 - // [incomplete] comprehension.t1.ok.p1.x.z: cyclic reference to field z: 166 + // [incomplete] comprehension.t1.ok.p1.x.z.a: cyclic reference to field z: 167 167 // ./comprehension.cue:18:3 168 168 // comprehension.t1.ok.p1.x.z.a: cyclic reference to field z: 169 169 // ./comprehension.cue:22:3 ··· 173 173 } 174 174 } 175 175 p2: (_|_){ 176 - // [incomplete] comprehension.t1.ok.p2.x.z: cyclic reference to field z: 176 + // [incomplete] comprehension.t1.ok.p2.x.z.a: cyclic reference to field z: 177 177 // ./comprehension.cue:28:3 178 178 // comprehension.t1.ok.p2.x.z.a: cyclic reference to field z: 179 179 // ./comprehension.cue:31:3 ··· 185 185 p3: (_|_){ 186 186 // [incomplete] comprehension.t1.ok.p3.x.z.a: cyclic reference to field z: 187 187 // ./comprehension.cue:39:3 188 - // comprehension.t1.ok.p3.x.z: cyclic reference to field z: 188 + // comprehension.t1.ok.p3.x.z.a: cyclic reference to field z: 189 189 // ./comprehension.cue:42:3 190 190 x: (struct){ 191 191 y: (struct){ ··· 195 195 p4: (_|_){ 196 196 // [incomplete] comprehension.t1.ok.p4.x.z.a: cyclic reference to field z: 197 197 // ./comprehension.cue:48:3 198 - // comprehension.t1.ok.p4.x.z: cyclic reference to field z: 198 + // comprehension.t1.ok.p4.x.z.a: cyclic reference to field z: 199 199 // ./comprehension.cue:52:3 200 200 x: (struct){ 201 201 y: (struct){ ··· 205 205 p5: (_|_){ 206 206 // [incomplete] comprehension.t1.ok.p5.x.z.a: cyclic reference to field z: 207 207 // ./comprehension.cue:58:3 208 - // comprehension.t1.ok.p5.x.z: cyclic reference to field z: 208 + // comprehension.t1.ok.p5.x.z.a: cyclic reference to field z: 209 209 // ./comprehension.cue:61:3 210 210 x: (struct){ 211 211 y: (struct){ ··· 321 321 - z: (struct){ 322 322 - a: (struct){ 323 323 - } 324 - + // [incomplete] comprehension.t1.ok.p0.x.z: cyclic reference to field z: 324 + + // [incomplete] comprehension.t1.ok.p0.x.z.a: cyclic reference to field z: 325 325 + // ./comprehension.cue:9:3 326 326 + // comprehension.t1.ok.p0.x.z.a: cyclic reference to field z: 327 327 + // ./comprehension.cue:12:3 ··· 339 339 - z: (struct){ 340 340 - a: (struct){ 341 341 - } 342 - + // [incomplete] comprehension.t1.ok.p1.x.z: cyclic reference to field z: 342 + + // [incomplete] comprehension.t1.ok.p1.x.z.a: cyclic reference to field z: 343 343 + // ./comprehension.cue:18:3 344 344 + // comprehension.t1.ok.p1.x.z.a: cyclic reference to field z: 345 345 + // ./comprehension.cue:22:3 ··· 387 387 - z: (struct){ 388 388 - a: (struct){ 389 389 - } 390 - + // [incomplete] comprehension.t1.ok.p2.x.z: cyclic reference to field z: 390 + + // [incomplete] comprehension.t1.ok.p2.x.z.a: cyclic reference to field z: 391 391 + // ./comprehension.cue:28:3 392 392 + // comprehension.t1.ok.p2.x.z.a: cyclic reference to field z: 393 393 + // ./comprehension.cue:31:3 ··· 399 399 + p3: (_|_){ 400 400 + // [incomplete] comprehension.t1.ok.p3.x.z.a: cyclic reference to field z: 401 401 + // ./comprehension.cue:39:3 402 - + // comprehension.t1.ok.p3.x.z: cyclic reference to field z: 402 + + // comprehension.t1.ok.p3.x.z.a: cyclic reference to field z: 403 403 + // ./comprehension.cue:42:3 404 404 + x: (struct){ 405 405 + y: (struct){ ··· 409 409 + p4: (_|_){ 410 410 + // [incomplete] comprehension.t1.ok.p4.x.z.a: cyclic reference to field z: 411 411 + // ./comprehension.cue:48:3 412 - + // comprehension.t1.ok.p4.x.z: cyclic reference to field z: 412 + + // comprehension.t1.ok.p4.x.z.a: cyclic reference to field z: 413 413 + // ./comprehension.cue:52:3 414 414 + x: (struct){ 415 415 + y: (struct){ ··· 419 419 + p5: (_|_){ 420 420 + // [incomplete] comprehension.t1.ok.p5.x.z.a: cyclic reference to field z: 421 421 + // ./comprehension.cue:58:3 422 - + // comprehension.t1.ok.p5.x.z: cyclic reference to field z: 422 + + // comprehension.t1.ok.p5.x.z.a: cyclic reference to field z: 423 423 + // ./comprehension.cue:61:3 424 424 + x: (struct){ 425 425 + y: (struct){ ··· 475 475 } 476 476 } 477 477 } 478 + -- diff/todo/p3 -- 479 + Error path location could improve. 478 480 -- diff/explanation -- 479 481 v0.7 fixes bugs in v0.6: 480 482 - t1 should be incomplete error, as it is fixable.
+9 -9
internal/core/adt/fields.go
··· 801 801 802 802 defer n.ctx.PopArc(n.ctx.PushArc(v)) 803 803 804 - // TODO: this block is not strictly needed. Removing it slightly changes the 805 - // paths at which errors are reported, arguably, but not clearly, for the 806 - // better. Investigate this once the new evaluator is done. 807 - if v.ArcType == ArcNotPresent { 808 - // It was already determined before that this arc may not be present. 809 - // This case can only manifest itself if we have a cycle. 810 - n.node.reportFieldCycleError(n.ctx, pos(c.x), f) 811 - return v, nil 812 - } 804 + // TODO: reporting the cycle error here results in better error paths. 805 + // However, it causes the reference counting mechanism to be faulty. 806 + // Reevaluate once the new evaluator is done. 807 + // if v.ArcType == ArcNotPresent { 808 + // // It was already determined before that this arc may not be present. 809 + // // This case can only manifest itself if we have a cycle. 810 + // n.node.reportFieldCycleError(n.ctx, pos(c.x), f) 811 + // return v, nil 812 + // } 813 813 814 814 if v.cc == nil { 815 815 v.cc = v.rootCloseContext(n.ctx)