Skip to content

Fix numbered parameters when used as a singleton #6415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

hoshiumiarata
Copy link
Contributor

It seems that using a numbered parameter as a singleton is generating an incorrect AST, so code like this is not working:

o = Object.new
o.tap { def _1.a(b) = "a#{b}" }

=> undefined method '_1' (NoMethodError)

It generates the following AST:

00002               NODE_SDEF:
00002                 NODE_FCALL:
00002                   method='_1' (31195136)
00002                 :a
00002                   mandatory args:
00002                     NODE_ARG b

I tried to fix it, so it generates the following AST now:

00002               NODE_SDEF:
00002                 NODE_NVAR 1
00002                 :a
00002                   mandatory args:
00002                     NODE_ARG b

I'm not sure if this is the best way to fix it, so it's okay to fix it in another way if it's better.

@hoshiumiarata hoshiumiarata requested a review from matz as a code owner November 12, 2024 15:37
@matz matz merged commit e0d9bce into mruby:master Nov 15, 2024
12 of 13 checks passed
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.

2 participants