Skip to content

Incorrect ArgumentError: wrong number of arguments #8382

@notEthan

Description

@notEthan

JRuby seems to get confused about method arity in some situation involving blocks and Enumerator.
I encountered this and have pared the code that triggers it down to this:

class BlockHolder
  def initialize(block)
    @block = block
  end

  def call(*a, **kw)
    @block.call(*a, **kw)
  end
end

class S
  def initialize
    to_enum(:call_via_blockholder).to_a
  end

  def call_via_blockholder(&block)
    BlockHolder.new(block).call
  end
end

def passkw(kw: )
end

passkw(kw: S.new)
  • JRuby version: jruby 9.4.8.0 (3.1.4) 2024-07-02 4d41e55 OpenJDK 64-Bit Server VM 17.0.5+8 on 17.0.5+8 +jit [x86_64-darwin]
  • also reproduces on 9.4.2.0
  • Operating system: consistent on macos and ubuntu

Expected Behavior: no error (passes on mri, truffleruby)
Actual Behavior: ArgumentError: wrong number of arguments (given 1, expected 0)
passkw at test.rb:21

at test.rb:24

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions