Skip to content

Keyword method parameters cannot take a frozen hash #2511

@blanquer

Description

@blanquer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions