Skip to content

Commit 894205c

Browse files
committed
internal/core/adt: dereference overlay
When we finalize the rewrites, it should be done on the overlay, not the original node. Not sure why this worked at all. It seems like this was the result of closeParent, which effectively blocked most rewrites. But in practice that didn't seem to matter either. In an upcoming CL we will actually rely on the rewrites. Issue #3935 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: I35a78a6062507c7d0c67a925ea2a698b9d59acc8 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1215576 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 1a2e80e commit 894205c

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

internal/core/adt/eval.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,9 +1066,6 @@ type nodeContext struct {
10661066
vLists []*Vertex
10671067
exprs []envExpr
10681068

1069-
// TODO: remove
1070-
closeParent *nodeContext
1071-
10721069
// These fields are used to track type checking.
10731070
reqDefIDs []refInfo
10741071
replaceIDs []replaceID

internal/core/adt/overlay.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,13 @@ func (ctx *overlayContext) cloneRoot(root *nodeContext) *nodeContext {
142142
v.state.vertexMap = ctx.vertexMap
143143

144144
for _, v := range ctx.vertices {
145+
v = v.overlay
146+
145147
n := v.state
146-
if n == nil || n.closeParent == nil {
148+
if n == nil {
147149
continue
148150
}
149151

150-
if p := n.closeParent.node; p.overlay != nil {
151-
// Use the new nodeContext if the node was cloned. Otherwise it
152-
// is fine to use the old one.
153-
n.closeParent = p.state
154-
if p.state == nil {
155-
panic("unexpected nil nodeContext")
156-
}
157-
}
158-
159152
// The group of the root closeContext should point to the Conjuncts field
160153
// of the Vertex. As we already allocated the group, we use that allocation,
161154
// but "move" it to v.Conjuncts.

0 commit comments

Comments
 (0)