Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue/ast: don't require ellipsis to be at end of struct.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mpvl committed Jun 16, 2020
1 parent 7aa2eb7 commit f5315d4
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cue/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (v *astVisitor) walk(astNode ast.Node) (ret value) {
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 {
Expand All @@ -213,9 +213,7 @@ func (v *astVisitor) walk(astNode ast.Node) (ret value) {
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)
Expand Down

0 comments on commit f5315d4

Please sign in to comment.