Parser: Don't output unexpected_token_close_context for <% if %>#824
Merged
Conversation
marcoroth
added a commit
that referenced
this pull request
Nov 9, 2025
) Follow up to #824, this pull request improves the `herb_extract_ruby_to_buffer_with_semicolons` function even further, so that it is also be able to deal ERB comments that have a leading space on a single line: ```erb <% if true %><% # Comment here %><%= hello %><% end %> ``` **Before** <img width="3390" height="834" alt="CleanShot 2025-11-09 at 03 13 24@2x" src="https://github.com/user-attachments/assets/8344c1b7-ee41-44d9-b5cd-2d605fc986e9" /> **After** Now, we only have a linter offense telling people to use `<%#`, but no parser errors anymore. <img width="3384" height="1032" alt="CleanShot 2025-11-09 at 03 14 16@2x" src="https://github.com/user-attachments/assets/721f1c74-6c06-4c88-a11b-e2e38615df96" />
marcoroth
added a commit
that referenced
this pull request
Nov 18, 2025
…902) This pull request changes the way the parser handles the `unexpected ";"` errors. In #824, we changed the `herb_extract_ruby_to_buffer_with_semicolons` method to only add semicolons when needed. This pull request reverts that. But instead of just outputting the `unexpected ";"` errors (as it was before #824), we check if the `;` was actually part of the source file. If it wasn't part of the source file we re-parse this individual `ERBContentNode` to check for syntax errors in the raw source of that `ERBContentNode` instead, which shouldn't have the semicolon and thus shouldn't append the `unexpected ";"` errors. Resolves #854 Resolves #865 Resolves #899
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.
This pull request improves the
herb_extract_ruby_to_buffer_with_semicolonsfunction, to only output;when needed.That way, when you have an actual syntax error in your Ruby code, it won't mention an error about
unexpected ";":Before
After
Instead, it shows you a
conditional_predicate_termerror.Resolves #135