Skip to content

Commit f5315d4

Browse files
committed
cue/ast: don't require ellipsis to be at end of struct.
This is a first step in generally allowing this, according to the modified step. The prevents a crash in case the input is incorrect. Change-Id: Ia3bcd697548684dcf09367e7fa51a19a758838c9 Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6323 Reviewed-by: Marcel van Lohuizen <[email protected]>
1 parent 7aa2eb7 commit f5315d4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cue/ast.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (v *astVisitor) walk(astNode ast.Node) (ret value) {
204204
astState: v.astState,
205205
object: obj,
206206
}
207-
for i, e := range n.Decls {
207+
for _, e := range n.Decls {
208208
switch x := e.(type) {
209209
case *ast.EmbedDecl:
210210
if v1.object.emit == nil {
@@ -213,9 +213,7 @@ func (v *astVisitor) walk(astNode ast.Node) (ret value) {
213213
v1.object.emit = mkBin(v.ctx(), token.NoPos, opUnify, v1.object.emit, v1.walk(x.Expr))
214214
}
215215
case *ast.Ellipsis:
216-
if i != len(n.Decls)-1 {
217-
return v1.walk(x.Type) // Generate an error
218-
}
216+
// handled elsewhere
219217

220218
default:
221219
v1.walk(e)

0 commit comments

Comments
 (0)