Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3171,6 +3171,8 @@ func (p *Parser) parseBracedNewConstructorField() *ast.BracedConstructorField {
fieldValue = &ast.BracedConstructorFieldValueExpr{Colon: colon, Expr: expr}
case "{":
fieldValue = p.parseBracedConstructor()
default:
p.panicfAtToken(&p.Token, "expected token: {, :, but: %s", p.Token.Kind)
}
return &ast.BracedConstructorField{Name: name, Value: fieldValue}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NEW foo { bar }
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--- !bad_new_braced_constructor_field_without_value.sql
NEW foo { bar }

--- Error
syntax error: testdata/input/expr/!bad_new_braced_constructor_field_without_value.sql:1:15: expected token: {, :, but: }
1| NEW foo { bar }
| ^
syntax error: testdata/input/expr/!bad_new_braced_constructor_field_without_value.sql:1:15: expected token: <eof>, but: }
1| NEW foo { bar }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error looks strange. We want to avoid it.

| ^


--- AST
&ast.BadExpr{
BadNode: &ast.BadNode{
NodeEnd: 13,
Tokens: []*token.Token{
&token.Token{
Kind: "NEW",
Raw: "NEW",
End: 3,
},
&token.Token{
Kind: "<ident>",
Space: " ",
Raw: "foo",
AsString: "foo",
Pos: 4,
End: 7,
},
&token.Token{
Kind: "{",
Space: " ",
Raw: "{",
Pos: 8,
End: 9,
},
&token.Token{
Kind: "<ident>",
Space: " ",
Raw: "bar",
AsString: "bar",
Pos: 10,
End: 13,
},
},
},
}

--- SQL
NEW foo { bar

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Furthermore, this lacks the closing brace }. It seems actually a bug.