Skip to content

Incorrect ArgumentError: wrong number of arguments #7804

@notEthan

Description

@notEthan

I have a method call which JRuby (9.4.2.0) seems to be incorrectly handling arguments for, raising "ArgumentError: wrong number of arguments (given 2, expected 1)", in particular circumstances. I haven't been able to come up with a standalone example to reproduce it but happens consistently with a library I maintain. A minimal script to trigger this, relying on that library:

require 'bundler/inline'
gemfile(install = true) do
  source 'https://rubygems.org'
  gem 'jsi', github: 'notEthan/jsi', ref: '5d1192f'
end

JSI::JSONSchemaOrgDraft07.schema.jsi_each_descendent_node { }

The commit introducing this is here: notEthan/jsi@5d1192f - the call from lib/jsi/schema/validation/ref.rb

Test workflow for that commit fails in JRuby: https://github.com/notEthan/jsi/actions/runs/5054298573/jobs/9069071917

I say 'particular circumstances' above - I haven't been successful coming up with a minimal, standalone script to reproduce because I can't tell what about the context triggers this. That same line of code is hit several times without erroring before the ArgumentError is raised (even with the exact same argument values). Changing the context slightly, e.g. removing or the jsi_memoize method (which caches the result of the block), or altering arguments to that method, causes the call to Schema::Ref.new to succeed without ArgumentError. I haven't been able to make sense of why, and this is as far as I have gotten with it.

Environment Information

  • JRuby version: jruby 9.4.2.0 (3.1.0) 2023-03-08 90d2913 OpenJDK 64-Bit Server VM 17.0.5+8 on 17.0.5+8 +jit [x86_64-darwin]
  • Operating system and platform: Darwin Kernel Version 21.6.0; root:xnu-8020.240.18.701.5~1/RELEASE_X86_64 x86_64
  • also reproduces on Ubuntu 22.04.

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