Skip to content
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

Bug: Opal follows Ruby <=2.6 rules regarding **kwargs #2241

Open
hmdne opened this issue Jun 23, 2021 · 4 comments
Open

Bug: Opal follows Ruby <=2.6 rules regarding **kwargs #2241

hmdne opened this issue Jun 23, 2021 · 4 comments

Comments

@hmdne
Copy link
Member

hmdne commented Jun 23, 2021

Describe the bug
As of now, Opal follows Ruby <=2.6 rules regarding how **kwargs are handled. See:

We have got only a preliminary **nil support, see: #2240

We support delegation 3.0 level, see: #2153

Note: I think that breaking with our unspoken policy of upgrading to new Ruby versions behavior not being considered a breaking change, this SHOULD be considered a breaking change and be targeted at a major version release. This change is the main reason of incompatibilies between Ruby 2.7 and 3.0 and I would say at least 50% of the code running using Opal is Opal specific (ie. not executed with Ruby). At best, we should try to match the Ruby 2.7 behavior in the 1.x lineup and warn when the last argument is a hash.

Opal version: master

@hmdne
Copy link
Member Author

hmdne commented Jun 23, 2021

Idea: If we are to refactor this, shouldn't kwargs be treated similarly to how block is currently handled? I'm not a big fan of defining $$p as a property of a function though.

@elia
Copy link
Member

elia commented Aug 9, 2021

@hmdne I agree 100% on the release plan toward the updated behavior.
About how to implement them, I thought for a long time that Ruby could benefit from a Symbol only keys version of Hashes which should be used for kwargs as well. This would lend itself to better performance and looks like MRI is internally doing something among those lines. For us that would also mean we could use pure JS objects to represent it and have the full-fledged Hash to be a subclass of it.

Thoughts on this direction?

@eregon
Copy link
Contributor

eregon commented Aug 16, 2021

FYI **kwargs can contain non-Symbols on Ruby 2.7+

@janbiedermann
Copy link
Member

See #2568

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants