Skip to content

Commit 86e62b2

Browse files
committed
internal/core/adt: simplify representation of outer scope
Now outerID both cannot be 0 and it is no longer used to mark an enclosingID as used, we can remove it. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: If86a2478280c57117972a4b039f527aa267ec9cf Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211955 Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 2cd5ba6 commit 86e62b2

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

internal/core/adt/closed.go

-3
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ type CloseInfo struct {
109109
defID defID
110110
enclosingEmbed defID // Tracks an embedding within a struct.
111111
outerID defID // Tracks the {} that should be closed after unifying.
112-
// hasOuter marks that an outer struct is present nad/or that an
113-
// enclosingEmbed groups has been "activated" (ignore set to false).
114-
hasOuter bool
115112

116113
// IsClosed is true if this conjunct represents a single level of closing
117114
// as indicated by the closed builtin.

internal/core/adt/conjunct.go

-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ func (n *nodeContext) scheduleVertexConjuncts(c Conjunct, arc *Vertex, closeInfo
355355
}
356356
c.CloseInfo.defID = closeInfo.defID
357357
c.CloseInfo.outerID = closeInfo.defID
358-
c.CloseInfo.hasOuter = false
359358

360359
key := arcKey{arc, ciKey}
361360
for _, k := range n.arcMap {

internal/core/adt/typocheck.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func (n *nodeContext) addResolver(v *Vertex, id CloseInfo, forceIgnore bool) Clo
266266

267267
if isClosed {
268268
for i, x := range n.reqDefIDs {
269-
if x.id == id.outerID && id.hasOuter {
269+
if x.id == id.outerID && id.outerID != 0 {
270270
n.reqDefIDs[i].ignore = false
271271
break
272272
}
@@ -280,7 +280,7 @@ func (n *nodeContext) addResolver(v *Vertex, id CloseInfo, forceIgnore bool) Clo
280280
// This is the case, for instance, if a resolver resolves to a
281281
// non-definition.
282282
ignore = true
283-
case id.enclosingEmbed != 0 || !id.hasOuter:
283+
case id.enclosingEmbed != 0 || id.outerID == 0:
284284
// We have a reference within an inner embedding group. If this is
285285
// a definition, or otherwise typo checked struct, we need to track
286286
// the embedding for mutual compatibility.
@@ -333,7 +333,6 @@ func (n *nodeContext) addResolver(v *Vertex, id CloseInfo, forceIgnore bool) Clo
333333
// subField updates a CloseInfo for subfields of a struct.
334334
func (c *OpContext) subField(ci CloseInfo) CloseInfo {
335335
ci.outerID = 0
336-
ci.hasOuter = false
337336
ci.enclosingEmbed = 0
338337
return ci
339338
}
@@ -428,14 +427,12 @@ func (n *nodeContext) splitDefID(s *StructLit, id CloseInfo) CloseInfo {
428427
// TODO(evalv3): use a more principled detection mechanism.
429428
// TODO: set this as a flag in StructLit so as to not have to
430429
// do the somewhat dangerous cast here.
431-
// id.hasOuter = true
432430
return id
433431
}
434432

435433
id, dstID := n.newGroup(id)
436434

437-
if !id.hasOuter {
438-
id.hasOuter = true
435+
if id.outerID == 0 {
439436
id.outerID = dstID
440437
}
441438

0 commit comments

Comments
 (0)