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
Closed

Keyword method parameters cannot take a frozen hash #2511

blanquer opened this issue Jan 23, 2015 · 1 comment

Comments

@blanquer
Copy link

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
Copy link
Member

enebo 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 as completed in a8e705c Apr 7, 2015
enebo added a commit that referenced this issue Apr 7, 2015
…hash. Fixes #2015 - Method keyword arguments are destructive"

This reverts commit a8e705c.
enebo added a commit that referenced this issue Apr 8, 2015
… 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
Projects
None yet
Development

No branches or pull requests

2 participants