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 counter related to close builtin

The spawnCloseContext used to pass isClosedOnce
might never be incremented itself. As a result
decDependent might never be called and the parent
never decremented.

We use the DEFER counter to agitate an increment
and decrement after the conjunct is added.

The case where the counter is removed is in
builtins/default, most notably the line:

Close: close(*{} | 0)

Note that this also increases a counter, which
is always a possibility. We deal with that later.

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I18e9759a7958addb36ad437b6be0f49f43d7ea6a
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207519
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>

+2 -1
+2
internal/core/adt/conjunct.go
··· 580 580 n.node.ClosedNonRecursive = true 581 581 var cc *closeContext 582 582 id, cc = id.spawnCloseContext(n.ctx, 0) 583 + cc.incDependent(n.ctx, DEFER, nil) 584 + defer cc.decDependent(n.ctx, DEFER, nil) 583 585 cc.isClosedOnce = true 584 586 585 587 if v, ok := x.BaseValue.(*Vertex); ok {
-1
internal/core/adt/eval_test.go
··· 76 76 // counter errors. 77 77 // TODO: These counters should all go to zero. 78 78 var skipDebugDepErrors = map[string]int{ 79 - "builtins/default": 1, 80 79 "compile/scope": 1, 81 80 "comprehensions/pushdown": 2, 82 81 "cycle/builtins": 2,