Skip to content

Commit

Permalink
internal/core/adt: unwrap ConjunctGroup in EnvExpr
Browse files Browse the repository at this point in the history
This does not seem to change anything, but it seems
that this is strictly a better thing to do and could prevent
bugs down the line.

Issue #2884

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I3b3673be258fd1d0ddfe7788531fbde9e170cf15
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194443
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
mpvl committed May 8, 2024
1 parent d281a75 commit a8ec4b7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/core/adt/composite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1387,9 +1387,17 @@ func (c Conjunct) EnvExpr() (*Environment, Expr) {
// evaluated.
func EnvExpr(env *Environment, elem Elem) (*Environment, Expr) {
for {
if c, ok := elem.(*Comprehension); ok {
env = linkChildren(env, c)
c := MakeConjunct(env, c.Value, CloseInfo{})
switch x := elem.(type) {
case *ConjunctGroup:
if len(*x) == 1 {
c := (*x)[0]
env = c.Env
elem = c.Elem()
continue
}
case *Comprehension:
env = linkChildren(env, x)
c := MakeConjunct(env, x.Value, CloseInfo{})
elem = c.Elem()
continue
}
Expand Down

0 comments on commit a8ec4b7

Please sign in to comment.