Skip to content

Use same logic as IR for kwarg handling in IO#write#8562

Merged
headius merged 2 commits intojruby:masterfrom
headius:r2k_kwargs_io_write
Jan 11, 2025
Merged

Use same logic as IR for kwarg handling in IO#write#8562
headius merged 2 commits intojruby:masterfrom
headius:r2k_kwargs_io_write

Conversation

@headius
Copy link
Member

@headius headius commented Jan 8, 2025

When passing kwargs from a ruby2_keywords method to a core "real keywords" method, we lose the keywordiness of the incoming hash and raise an argument error for the arity mismatch. By using the same logic as IR here, we properly handle the incoming r2k hash.

This same patch could be applied generally to all core methods that accept keywords, but given the rarity of r2k to core "real keywords" methods we have chosen to only do targeted fixes. This reduces the potential impact (versus a new, more general solution) and the required work (9.4.10 is eagerly awaited). We will explore more reliable, general improvements to core method kwarg handling in JRuby 10.

Fixes #8398.

When passing kwargs from a ruby2_keywords method to a core "real
keywords" method, we lose the keywordiness of the incoming hash
and raise an argument error for the arity mismatch. By using the
same logic as IR here, we properly handle the incoming r2k hash.

This same patch could be applied generally to all core methods that
accept keywords, but given the rarity of r2k to core "real
keywords" methods we have chosen to only do targeted fixes. This
reduces the potential impact (versus a new, more general solution)
and the required work (9.4.10 is eagerly awaited). We will explore
more reliable, general improvements to core method kwarg handling
in JRuby 10.

Fixes jruby#8398.
@headius headius force-pushed the r2k_kwargs_io_write branch from 0babfc2 to 4c00e56 Compare January 8, 2025 22:14
@headius headius requested a review from enebo January 10, 2025 17:18
@headius
Copy link
Member Author

headius commented Jan 11, 2025

@enebo I'm going to merge this. Let me know if you see any issues.

@headius headius merged commit 01d88c3 into jruby:master Jan 11, 2025
95 checks passed
@headius headius deleted the r2k_kwargs_io_write branch January 11, 2025 01:47
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.

ruby2_keywords + forwarding to native does not properly check arity

1 participant