AaronC81 · GitHub

For this code example:

class X
  def initialize(x:)
    puts x
  end
  def something_else(x:)
    puts x
  end
end
class Y < X
  def initialize
    something_else(x: 1)
    super(x: 2)
  end
end
Y.new

On the current master branch of MRuby ( 84b5b4c ), I get the following output:

1
trace (most recent call last):
	[3] t.rb:19
	[2] t.rb:19:in new
	[1] t.rb:15:in initialize
t.rb:2:in initialize: missing keyword: x (ArgumentError)

The super call is throwing an exception, saying that it's missing the keyword argument x, even though it is actually passed. The first 1 gets output OK, so the keyword parameter seems to be working OK in a standard method call, but not a super call.

If x is made a positional argument rather than a keyword argument, then the super calls works OK.

This code produces the expected output of 1 2 on my system's installation of MRuby from Homebrew (3.0.0 2021-03-05) and on MRI (3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin21]).

Read the original on github.com ↗