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

Method keyword arguments are destructive #2015

Closed
indrekj opened this Issue Oct 1, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@indrekj
Copy link

indrekj commented Oct 1, 2014

ruby -v: jruby 9000.dev-SNAPSHOT (2.1.2p142) 2014-10-01 d3df63c Java HotSpot(TM) 64-Bit Server VM 24.65-b04 on 1.7.0_67-b01 [darwin-x86_64]

example:

def foo(bar: 'baz'); end
opts = {bar: 'something'}
foo(opts)
opts #=> {}

In MRI 2.1.3 the same code:

def foo(bar: 'baz'); end
opts = {bar: 'something'}
foo(opts)
opts #=> {:bar=>"something"}
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Jan 20, 2015

Reported by someone else and I remembered this issue. So some notes:

  1. Caused by not dup'ing the kwargs list and our resolution algo removes elts to make sure all reqd elements are present (including duplicated values)
  2. in IR each kwarg is received via instruction and we call this fairly expense extractKwargsHash each time

Simplest way to fix in the short-term would be to not remove elements from the kwargs list but #2 is pretty sucky so I don't think doing that is the long term fix. We ultimately do not want to remove elts (+ dup) and we don't want to keep refiguring out the kwargs hash once per kwarg parameter.

@enebo enebo modified the milestones: 9.0.0.0.pre2, JRuby 9.0.0.0 Jan 24, 2015

@enebo enebo closed this in a8e705c Apr 7, 2015

enebo added a commit that referenced this issue Apr 7, 2015

Revert "Fixes #2511 - Keyword method parameters cannot take a frozen …
…hash. Fixes #2015 - Method keyword arguments are destructive"

This reverts commit a8e705c.

enebo added a commit that referenced this issue Apr 8, 2015

Revert "Revert "Fixes #2511 - Keyword method parameters cannot take a…
… frozen hash. Fixes #2015 - Method keyword arguments are destructive""

This reverts commit 4c86703.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.