Skip to content

Commit a833722

Browse files
committed
internal/core/adt: fix EVAL counter issue
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]>
1 parent ad7b84b commit a833722

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

internal/core/adt/eval_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var needFix = map[string]string{
7878
var skipDebugDepErrors = map[string]int{
7979
"cycle/disjunction": 1,
8080
"cycle/structural": 1,
81-
"disjunctions/elimination": 6,
81+
"disjunctions/elimination": 4,
8282
"eval/issue545": 1,
8383
"eval/notify": 3,
8484
}

internal/core/adt/overlay.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,16 @@ func (ctx *overlayContext) initCloneCC(x *closeContext) {
351351
o.Patterns = append(o.Patterns, x.Patterns...)
352352

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

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

471+
// Since have not started processing the disjunct yet, all EVAL
472+
// dependencies will have been initiated outside of this disjunct.
473+
if d.kind == EVAL {
474+
o.decDependentNoMatch(ctx.ctx, EVAL, nil)
475+
continue
476+
}
477+
470478
if d.dependency.overlay == nil {
471479
// This dependency is irrelevant for the current overlay. We can
472480
// eliminate it as long as we decrement the accompanying counter.

0 commit comments

Comments
 (0)