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

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

Open
mvz opened this issue Sep 29, 2019 · 0 comments

Comments

@mvz
Copy link

commented Sep 29, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.