Skip to content

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

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

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

Conversation

@marcoroth

@marcoroth marcoroth commented Feb 23, 2026

Copy link
Copy Markdown
Owner

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

@github-actions github-actions Bot added parser HTML+ERB parser c C source for the core parser, lexer, and AST labels Feb 23, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 23, 2026

Copy link
Copy Markdown
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

github-actions Bot commented Feb 23, 2026

Copy link
Copy Markdown

🌿 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
@marcoroth marcoroth added this to the v1.0.0 milestone Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c C source for the core parser, lexer, and AST parser HTML+ERB parser

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant