Skip to content

Fix destructuring of block argument with default value#9376

Merged
headius merged 1 commit into
jruby:masterfrom
katafrakt:fix-destructuring-with-default-value
May 5, 2026
Merged

Fix destructuring of block argument with default value#9376
headius merged 1 commit into
jruby:masterfrom
katafrakt:fix-destructuring-with-default-value

Conversation

@katafrakt

Copy link
Copy Markdown
Contributor

It fixes #9375 - incorrect behaviour found in instance_exec, module_exec and class_exec:

Object.new.instance_exec([1, 2]) { |x = :unset| x } 
=> 1

The fix is similar to #9211

The alternative I considered is to maybe put that logic (sig.opt() + sig.required() == 1 && !sig.hasRest()) but I'm not sure it would be correct. Sounds like it, but it's not how the fix was applied in the other PR. Will be happy to change.

It fixes incorrect behaviour found in instance_exec, module_exec and
class_exec:

Object.new.instance_exec([1, 2]) { |x = :unset| x }
=> 1

@headius headius left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems simple enough for now, just narrowing the cases where we expand that argument. Needs a long-term cleanup at some point.

@headius headius added this to the JRuby 10.1.1.0 milestone May 5, 2026
@headius
headius merged commit 35d2a8f into jruby:master May 5, 2026
107 checks passed
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.

instance_exec block argument destructuring when default value passed

2 participants