Skip to content

Keyword parameters not passing through super correctly on current master #5660

@AaronC81

Description

@AaronC81

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]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions