Skip to content

Commit

Permalink
internal/core/adt: match decrement for nested comprehension arcs
Browse files Browse the repository at this point in the history
The current logic for closedness counter matching did not account
for nested arcs in comprehensions, causing errors to be reported
when adt.DebugDeps was set to false.

This does not fix any tests, but it will reduce the number of errors
reported setting DebugDeps to true, which is currently set to false.

Issue #2884

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: Ie3efec2d30bdab0ea6802cf9d1f978e5a51abdc3
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1193641
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
  • Loading branch information
mpvl committed Apr 23, 2024
1 parent d900867 commit edda26d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions internal/core/adt/comprehension.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (n *nodeContext) insertComprehension(
}

if ec.done && len(ec.envs) == 0 {
n.decComprehension(c)
return
}

Expand Down Expand Up @@ -408,14 +409,21 @@ func (n *nodeContext) processComprehension(d *envYield, state vertexStatus) *Bot
// NOTE: we cannot move this to defer in processComprehensionInner, as we
// use panics to implement "yielding" (and possibly coroutines in the
// future).
cc := d.leaf.cc
if cc != nil {
cc.decDependent(n.ctx, COMP, d.leaf.arcCC)
}
d.leaf.cc = nil
n.decComprehension(d.leaf)

return err
}

func (n *nodeContext) decComprehension(p *Comprehension) {
for ; p != nil; p = p.parent {
cc := p.cc
if cc != nil {
cc.decDependent(n.ctx, COMP, p.arcCC)
}
p.cc = nil
}
}

func (n *nodeContext) processComprehensionInner(d *envYield, state vertexStatus) *Bottom {
ctx := n.ctx

Expand Down

0 comments on commit edda26d

Please sign in to comment.