Skip to content

Commit f045a5a

Browse files
committed
internal/core/adt: make comprehension value an Expr
Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Change-Id: I070f9b8985762d45e11467e39dbba535f0f2d21f Signed-off-by: Marcel van Lohuizen <mpvl@golang.org> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/529521 Reviewed-by: Paul Jolly <paul@myitcv.io>
1 parent 448b94c commit f045a5a

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

internal/core/adt/adt.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ func (*StructLit) expr() {}
183183
func (*ListLit) expr() {}
184184
func (*DisjunctionExpr) expr() {}
185185

186+
// TODO: also allow?
187+
// a: b: if cond {}
188+
//
189+
// It is unclear here, though, whether field `a` should be added
190+
// unconditionally.
191+
// func (*Comprehension) expr() {}
192+
186193
// Expr and Value
187194

188195
func (*Bottom) expr() {}

internal/core/adt/composite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ func (v *Vertex) Value() Value {
325325
case *StructMarker, *ListMarker:
326326
return v
327327
case Value:
328+
// TODO: recursively descend into Vertex?
328329
return x
329330
default:
330331
panic(fmt.Sprintf("unexpected type %T", v.BaseValue))
@@ -455,8 +456,7 @@ func (v *Vertex) Finalize(c *OpContext) {
455456
}
456457

457458
func (v *Vertex) AddErr(ctx *OpContext, b *Bottom) {
458-
v.BaseValue = CombineErrors(nil, v.Value(), b)
459-
v.UpdateStatus(Finalized)
459+
v.SetValue(ctx, Finalized, CombineErrors(nil, v.Value(), b))
460460
}
461461

462462
func (v *Vertex) SetValue(ctx *OpContext, state VertexStatus, value BaseValue) *Bottom {

internal/core/adt/expr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ func (x *Disjunction) Kind() Kind {
16061606

16071607
type Comprehension struct {
16081608
Clauses Yielder
1609-
Value *StructLit // TODO: changes this to Expr?
1609+
Value Expr
16101610
}
16111611

16121612
func (x *Comprehension) Source() ast.Node {

0 commit comments

Comments
 (0)