Skip to content

Commit

Permalink
internal/core/adt: fix EVAL counter issue
Browse files Browse the repository at this point in the history
See the various comments in the change for
an explanation of this change.

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: Ib5da63c457a5061efd9e46733084f6a9c6959456
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207748
Reviewed-by: Matthew Sackman <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
  • Loading branch information
mpvl committed Jan 28, 2025
1 parent ad7b84b commit a833722
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion internal/core/adt/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var needFix = map[string]string{
var skipDebugDepErrors = map[string]int{
"cycle/disjunction": 1,
"cycle/structural": 1,
"disjunctions/elimination": 6,
"disjunctions/elimination": 4,
"eval/issue545": 1,
"eval/notify": 3,
}
Expand Down
26 changes: 17 additions & 9 deletions internal/core/adt/overlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,16 @@ func (ctx *overlayContext) initCloneCC(x *closeContext) {
o.Patterns = append(o.Patterns, x.Patterns...)

// needsCloseInSchedule is a separate mechanism to signal nodes that have
// completed. Do not signal such nodes if they are outside the current
// copied graph.
if cx := x.needsCloseInSchedule; cx != nil {
if cx.src._cc.overlay == nil {
o.needsCloseInSchedule = nil
} else {
// TODO: Debug assert: cx.overlay != nil
o.needsCloseInSchedule = ctx.allocCC(cx)
}
// completed that corresponds to the EVAL mechanism. Since we have not
// processed the conjuncts yet, these are inherently initiated outside of
// this conjunct. By now, if a closeContext needs to remain open, other
// counters should have been added. As an example, the parent node of this
// disjunct is still processing. The disjunction will be fully added before
// processing, and thus their will be no direct EVAL dependency. However,
// this disjunct may depend on a NOTIFY that is kept open by an ancestor
// EVAL.
if x.needsCloseInSchedule != nil {
o.needsCloseInSchedule = nil
}

// child and next always point to completed closeContexts. Moreover, only
Expand Down Expand Up @@ -467,6 +468,13 @@ func (ctx *overlayContext) finishDependencies(x *closeContext) {
continue
}

// Since have not started processing the disjunct yet, all EVAL
// dependencies will have been initiated outside of this disjunct.
if d.kind == EVAL {
o.decDependentNoMatch(ctx.ctx, EVAL, nil)
continue
}

if d.dependency.overlay == nil {
// This dependency is irrelevant for the current overlay. We can
// eliminate it as long as we decrement the accompanying counter.
Expand Down

0 comments on commit a833722

Please sign in to comment.