Skip to content

Hash#each raises ArgumentError with a method of arity 2 converted to a block #5896

@mvz

Description

@mvz

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b OpenJDK 64-Bit Server VM 11.0.5-ea+6-post-Debian-2 on 11.0.5-ea+6-post-Debian-2 [linux-x86_64]
JRUBY_OPTS=--dev
JAVA_OPTS=" --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.security.cert=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/javax.crypto=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.base/java.nio.channels.spi=ALL-UNNAMED --illegal-access=warn"
  • Operating system and platform (e.g. uname -a)
Linux bean 5.2.0-2-amd64 #1 SMP Debian 5.2.9-2 (2019-08-21) x86_64 GNU/Linux

Expected Behavior

Given the following Ruby script:

class Bar
  def foo
    { a: 1, b: 2}.each(&method(:bar))
  end

  def bar(a, b)
    puts "#{a}: #{b}"
  end
end

Bar.new.foo

CRuby has the following output:

a: 1
b: 2

Actual Behavior

JRuby has the following output:

ArgumentError: wrong number of arguments (given 1, expected 2)
     bar at foo.rb:3
    each at org/jruby/RubyHash.java:1419
     foo at foo.rb:3
  <main> at foo.rb:11

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions