Skip to content

Allow named_ref on parameterized rule calls inside %rule#778

Merged
ydah merged 1 commit intoruby:masterfrom
ydah:allow_named_ref_on_parameterized_rule
Mar 1, 2026
Merged

Allow named_ref on parameterized rule calls inside %rule#778
ydah merged 1 commit intoruby:masterfrom
ydah:allow_named_ref_on_parameterized_rule

Conversation

@ydah
Copy link
Member

@ydah ydah commented Mar 1, 2026

In rule_rhs, the production for IDENTIFIER "(" parameterized_args ")" was missing named_ref?, making it impossible to write f_opt_arg(value)[opt] inside a %rule body (parse error on [).

In `rule_rhs`, the production for `IDENTIFIER "(" parameterized_args ")"` was
missing `named_ref?`, making it impossible to write `f_opt_arg(value)[opt]`
inside a `%rule` body (parse error on `[`).

- Add `named_ref?` before `TAG?` in the `rule_rhs` parameterized call production
  to match the equivalent `rhs` production (regular rules already supported this)
- Propagate `alias_name` through `Binding#create_instantiate_rule` so that
  named references are preserved when resolving parameter bindings, allowing
  `numberize_references` to correctly resolve `$opt`-style references in actions
@ydah ydah marked this pull request as ready for review March 1, 2026 01:36
@ydah ydah merged commit e8dbb06 into ruby:master Mar 1, 2026
23 checks passed
@ydah ydah deleted the allow_named_ref_on_parameterized_rule branch March 1, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant