Skip to content

Keyword arguments arity error in drb tests #8798

Description

@headius

There's an arity error in the drb tests when running on JRuby 10 (have not tested 9.4):

$ bundle exec ruby -Ilib:test/lib test/drb/test_drb.rb -n test_bug16634
Loaded suite test/drb/test_drb
Started
E
===========================================================================================================================================================================================================================================================================================================================================
Error: test_bug16634(DRbTests::TestBug16634): ArgumentError: wrong number of arguments (given 1, expected 0)
(druby://localhost:51803) /Users/headius/work/drb/test/drb/ut_drb.rb:151:in 'keyword_test1'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1713:in 'perform_without_block'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1669:in 'perform'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1758:in 'block in main_loop'
(druby://localhost:51803) org/jruby/RubyKernel.java:1658:in 'loop'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1754:in 'block in main_loop'
test/drb/test_drb.rb:364:in 'test_bug16634'
     361:   end
     362: 
     363:   def test_bug16634
  => 364:     assert_equal(42, @there.keyword_test1(a: 42))
     365:     assert_equal("default", @there.keyword_test2)
     366:     assert_equal(42, @there.keyword_test2(b: 42))
     367:     assert_equal({:a=>42, :b=>42}, @there.keyword_test3(a: 42, b: 42))

I have not investigated this yet but it may be a method generated by drb as a remote binding, and that could be a clue about why it sees this as a mismatched arity.

Activity

  1. kou commented on Apr 27, 2025

    @kou
    Contributor

    It seems that Marshal.load(Marshal.dump(ruby2_keywords_hash)) loses ruby2_keywords information:

    class DRbEx
      def keyword_test1(a:)
        a
      end
    end
    
    class Wrapper
      def initialize(object)
        @object = object
      end
    
      ruby2_keywords def method_missing(method, *args, &block)
        args = args.collect {|arg| Marshal.load(Marshal.dump(arg))}
        p Hash.ruby2_keywords_hash?(args[0]) # This is true with CRuby but false with JRuby
        @object.__send__(method, *args, &block)
      end
    end
    
    Wrapper.new(DRbEx.new).keyword_test1(a: 42)
  2. headius commented on Jul 8, 2025

    @headius
    MemberAuthor

    @kou Thanks for that help. Hopefully we can fix for 10.0.1.0.

  3. added a commit that references this issue on Jul 10, 2025
    2d6c77c
  4. linked a pull request that will close this issueImplement ruby2_keywords_hash dumping #8905on Jul 10, 2025
  5. added this to the JRuby 10.0.1.0 milestone on Jul 10, 2025
  6. headius commented on Jul 10, 2025

    @headius
    MemberAuthor

    Fixed with specs in #8905!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions