Skip to content

Comments

Parser: Improve ERB case node and end tag matching#1237

Merged
marcoroth merged 1 commit intomainfrom
parser-improve-case-end-matching
Feb 23, 2026
Merged

Parser: Improve ERB case node and end tag matching#1237
marcoroth merged 1 commit intomainfrom
parser-improve-case-end-matching

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Feb 23, 2026

This pull request improves the parser by properly matching <% end %> tags to ERBCaseNode when no when/in clauses are present.

For the following example:

<% case 1 %>
<% end %>

The reported errors are now reduced to 1, down from 3.

Before

Errors (3 total)

  1. RubyParseError at test.html.erb:1:3
     case_missing_conditions: expected a `when` or `in` clause after `case`

  2. MissingERBEndTagError at test.html.erb:1:0
     `<% case %>` started here but never closed with an end tag. The end tag may be in a different scope.

  3. ERBControlFlowScopeError at test.html.erb:2:0
     `<% end %>` appears outside its control flow block. Keep ERB control flow statements together within the same HTML scope (tag, attribute, or content).

After

Errors (1 total)

  1. RubyParseError at test.html.erb:1:3
     case_missing_conditions: expected a `when` or `in` clause after `case`

Inspired by ruby-gettext/gettext#117

/cc @joelhawksley

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 23, 2026

npx https://pkg.pr.new/@herb-tools/formatter@1237
npx https://pkg.pr.new/@herb-tools/language-server@1237
npx https://pkg.pr.new/@herb-tools/linter@1237

commit: 99a25b7

@github-actions
Copy link

github-actions bot commented Feb 23, 2026

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 99a25b7


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit 3fca26a into main Feb 23, 2026
29 of 31 checks passed
@marcoroth marcoroth deleted the parser-improve-case-end-matching branch February 23, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant