Skip to content

Commit ae730eb

Browse files
committed
internal/core/adt: break notification dependency on structural cycle
This case is specifically is not handled if structure sharing is off, or when a let is involved. Consider, for instance, this case: a: next: X let X = a Here, `a` is substituted for `X`, after which a structural cycle is detected. At this point, any notification resulting from X should be cancelled. Basically, cycle detection followed a different path, where this was not done. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Iba7a4399fb4d52d87c4ccfb3adba3bf79f14ca4b Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207520 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent aa6781f commit ae730eb

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

internal/core/adt/conjunct.go

+4
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ func (n *nodeContext) addNotify2(v *Vertex, c CloseInfo) {
554554

555555
cc := c.cc
556556

557+
// TODO: it should not be necessary to register for notifications for
558+
// let expressions, so we could also filter for !n.node.Label.IsLet().
559+
// However, somehow this appears to result in slightly better error
560+
// messages.
557561
if root.addNotifyDependency(n.ctx, cc) {
558562
// TODO: this is mostly identical to the slice in the root closeContext.
559563
// Use only one once V2 is removed.

internal/core/adt/eval_test.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,11 @@ var needFix = map[string]string{
7676
// counter errors.
7777
// TODO: These counters should all go to zero.
7878
var skipDebugDepErrors = map[string]int{
79-
"compile/scope": 1,
80-
"comprehensions/pushdown": 2,
8179
"cycle/builtins": 2,
8280
"cycle/comprehension": 1,
8381
"cycle/disjunction": 4,
84-
"cycle/evaluate": 1,
8582
"cycle/issue990": 1,
86-
"cycle/structural": 9,
83+
"cycle/structural": 7,
8784
"disjunctions/errors": 3,
8885
"disjunctions/elimination": 19,
8986
"disjunctions/nested": 1,

internal/core/adt/unify.go

+7-4
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ func (v *Vertex) unify(c *OpContext, needs condition, mode runMode) bool {
285285
case needs&subFieldsProcessed != 0:
286286
switch {
287287
case assertStructuralCycleV3(n):
288+
n.breakIncomingDeps()
288289
// TODO: consider bailing on error if n.errs != nil.
289290
case n.completeAllArcs(needs, mode):
290291
}
@@ -462,13 +463,15 @@ func (n *nodeContext) completeNodeTasks(mode runMode) {
462463
}()
463464
}
464465

465-
if p := v.Parent; p != nil && p.state != nil {
466-
if !v.IsDynamic && n.completed&allAncestorsProcessed == 0 {
467-
p.state.completeNodeTasks(mode)
466+
if !v.Label.IsLet() {
467+
if p := v.Parent; p != nil && p.state != nil {
468+
if !v.IsDynamic && n.completed&allAncestorsProcessed == 0 {
469+
p.state.completeNodeTasks(mode)
470+
}
468471
}
469472
}
470473

471-
if v.IsDynamic || v.Parent.allChildConjunctsKnown() {
474+
if v.IsDynamic || v.Label.IsLet() || v.Parent.allChildConjunctsKnown() {
472475
n.signal(allAncestorsProcessed)
473476
}
474477

0 commit comments

Comments
 (0)