Skip to content

Commit 0ccf38c

Browse files
committed
internal/core/adt: fix notification CloseInfo
Theoretically we should use the closeID that was passed upon registering the notification. Although this seems to have no effect, we add it for good posterity. We also update all defIDs from a passed in CloseID. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I6ceb2105bdb4c3c54d3c2f6deb4cde85fedf237d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1218817 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 840ff27 commit 0ccf38c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

internal/core/adt/conjunct.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ func (n *nodeContext) scheduleVertexConjuncts(c Conjunct, arc *Vertex, closeInfo
363363
closeInfo = n.addResolver(arc, closeInfo, true)
364364
}
365365
c.CloseInfo.defID = closeInfo.defID
366-
c.CloseInfo.outerID = closeInfo.defID
366+
c.CloseInfo.outerID = closeInfo.outerID
367+
c.CloseInfo.enclosingEmbed = closeInfo.enclosingEmbed
367368

368369
key := arcKey{arc, ciKey}
369370
for _, k := range n.arcMap {
@@ -409,6 +410,7 @@ func (n *nodeContext) addNotify2(v *Vertex, c CloseInfo) {
409410

410411
for _, r := range n.notify {
411412
if r.v == v {
413+
// TODO: might need to add replacement here.
412414
return
413415
}
414416
}
@@ -423,7 +425,7 @@ func (n *nodeContext) addNotify2(v *Vertex, c CloseInfo) {
423425
// messages.
424426
n.ctx.stats.Notifications++
425427

426-
n.notify = append(n.notify, receiver{v})
428+
n.notify = append(n.notify, receiver{v, c})
427429
}
428430

429431
// Literal conjuncts

internal/core/adt/eval.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1280,6 +1280,7 @@ type nodeContextState struct {
12801280
// v is equal to cc.src._cc in V3.
12811281
type receiver struct {
12821282
v *Vertex
1283+
c CloseInfo
12831284
}
12841285

12851286
// Logf substitutes args in format. Arguments of type Feature, Value, and Expr
@@ -1304,7 +1305,7 @@ func (n *nodeContext) addNotify(v *Vertex) {
13041305
unreachableForDev(n.ctx)
13051306

13061307
if v != nil && !n.node.hasAllConjuncts {
1307-
n.notify = append(n.notify, receiver{v})
1308+
n.notify = append(n.notify, receiver{v: v})
13081309
}
13091310
}
13101311

internal/core/adt/fields.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (v *Vertex) insertConjunct(ctx *OpContext, c Conjunct, id CloseInfo, mode A
233233
// TODO: we should probably only notify a conjunct once the root of the
234234
// conjunct group is completed. This will make it easier to "stitch" the
235235
// conjunct trees together, as its correctness will be guaranteed.
236-
rec.v.state.scheduleConjunct(c, id)
236+
rec.v.state.scheduleConjunct(c, rec.c)
237237
}
238238

239239
return

0 commit comments

Comments
 (0)