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

Keyword method parameters cannot take a frozen hash #2511

Closed
blanquer opened this Issue Jan 23, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@blanquer
Copy link

commented Jan 23, 2015

It seems that Jruby tries to mess (in some way or another) with the parameters hash that is passed to a method. If one passes those named parameters using a true hash, that it is frozen, Jruby complains it cannot modify a frozen hash.

Here's the smallest repro I could get:

class Foo
  def self.test( arg1: "default" )
    puts "arg1: #{arg1.inspect}"
  end
end

normal_args =  {arg1: "normal"}
frozen_args =  {arg1: "frozen"}.freeze

Foo.test( normal_args ) #=> succeeds
Foo.test( frozen_args ) #=> bails out RuntimeError: can't modify frozen Hash

with mri 2.2.0:

arg1: "normal"
arg1: "frozen"

with jruby-head (as of today):

arg1: "normal"
RuntimeError: can't modify frozen Hash
      delete at org/jruby/RubyHash.java:1574
  __script__ at /tmp/test.rb:11

Oh, and BTW, the original error that I saw in my application somehow complained more loudly about it:

BUG: Got exception org.jruby.exceptions.RaiseException: (RuntimeError) can't modify frozen Hash but instr using(0:0) = recv_kw_arg(0, using) is not supposed to be raising exceptions!

For what it's worth.

@enebo enebo added this to the 9.0.0.0.pre2 milestone Jan 24, 2015

@enebo

This comment has been minimized.

Copy link
Member

commented Jan 24, 2015

Our kwarg handling is not dup'ing kwargs hash which leads to issues like this and #2015. We will get this solved for pre2.

@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.