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 <mpvl@golang.org>
diff --git a/cue/ast.go b/cue/ast.go
index a79dc51..1f322c7 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -204,7 +204,7 @@
astState: v.astState,
object: obj,
}
- for i, e := range n.Decls {
+ for _, e := range n.Decls {
switch x := e.(type) {
case *ast.EmbedDecl:
if v1.object.emit == nil {
@@ -213,9 +213,7 @@
v1.object.emit = mkBin(v.ctx(), token.NoPos, opUnify, v1.object.emit, v1.walk(x.Expr))
}
case *ast.Ellipsis:
- if i != len(n.Decls)-1 {
- return v1.walk(x.Type) // Generate an error
- }
+ // handled elsewhere
default:
v1.walk(e)