Prevent internal ruby failure on invalid braces #455
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.
""}
is invalid syntax, and while running it, Ripper tries to runon_embexpr_end
to try and handle it as if it were the closing brace of an embexpr. However, in that case, we get aNoMethodError
for trying to append to an array that isn't there (since we didn't callon_embexpr_beg
. This is absolutely a weird edge case, but handling it means we correctly report this as a syntax error instead of an internal ruby error.(There might be something to do here for a more sustainable solution, which is something like if we run into an internal ruby error, call the parser directly without
rubyfmt_lib
and see if it parses correctly, but I'll leave that as an idea for a later day.)