Reject braced constructor field without value - #422
Open
makenowjust wants to merge 1 commit into
Open
Conversation
Collaborator
Author
|
@apstndb Could you review this? |
makenowjust
commented
Sep 4, 2026
| 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 } |
Collaborator
Author
There was a problem hiding this comment.
This error looks strange. We want to avoid it.
makenowjust
commented
Sep 4, 2026
| } | ||
|
|
||
| --- SQL | ||
| NEW foo { bar |
Collaborator
Author
There was a problem hiding this comment.
Furthermore, this lacks the closing brace }. It seems actually a bug.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #418.
parseBracedNewConstructorFieldswitched on:and{but had nodefaultcase, so a field followed by anything else (e.g.NEW A00{A0}, where the field is followed by}) produced aBracedConstructorFieldwith a nilValue— anderr == nil.SQL()and the position accessors then dereferenced the nil value and panicked.A braced constructor field requires a value, so the parser now reports it as a syntax error:
Error recovery wraps the expression in an
ast.BadExpras usual.Tests
testdata/input/expr/!bad_new_braced_constructor_field_without_value.sql(NEW foo { bar }) with its generated result, alongside the existing!bad_new_braced_constructor.sql.