Skip to content

Parser: Don't search for Action View Tag Helpers recursively#1431

Merged
marcoroth merged 1 commit intomainfrom
dont-search-for-tag-helpers-recurisvly
Mar 20, 2026
Merged

Parser: Don't search for Action View Tag Helpers recursively#1431
marcoroth merged 1 commit intomainfrom
dont-search-for-tag-helpers-recurisvly

Conversation

@marcoroth
Copy link
Owner

@marcoroth marcoroth commented Mar 20, 2026

This pull request fixes a bug in the parser analysis phase with action_view_helpers: true enabled where search_tag_helper_node would recursively traverse the entire Prism AST of an ERB expression, causing tag helpers nested inside another call's arguments or block body to be incorrectly detected and transformed as the top-level tag helper.

For example, the following template:

<% content_for :head, tag.meta(name: "viewport", content: "width=device-width, initial-scale=1") %>

Would incorrectly transform the ERBContentNode as if tag.meta were the outermost call. It now correctly produces the following using action_view_helpers: true:

@ DocumentNode (location: (1:0)-(2:0))
└── children: (2 items)
    ├── @ ERBContentNode (location: (1:0)-(1:99))
       ├── tag_opening: "<%" (location: (1:0)-(1:2))
       ├── content: " content_for :head, tag.meta(name: "viewport", content: "width=device-width, initial-scale=1") " (location: (1:2)-(1:97))
       ├── tag_closing: "%>" (location: (1:97)-(1:99))
       ├── parsed: true
       └── valid: true
    
    └── @ HTMLTextNode (location: (1:99)-(2:0))
        └── content: "\n"

The fix stops recursion at any PM_CALL_NODE that doesn't match a known tag helper. A tag helper must be the outermost call in the ERB expression, not nested inside another call's arguments or block body.

Resolves #1423
Resolves #1429

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 20, 2026

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

commit: 5dadfa1

@github-actions
Copy link

github-actions bot commented Mar 20, 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 5dadfa1


✅ Preview deployment has been cleaned up.

@marcoroth marcoroth merged commit ae806a8 into main Mar 20, 2026
39 checks passed
@marcoroth marcoroth deleted the dont-search-for-tag-helpers-recurisvly branch March 20, 2026 02:08
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.

Linter: "Failed to initialize buffer with capacity of X" error Parser: Don't transform Action View tag helpers nested in other method calls

1 participant