Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
AaronC81 opened this issue Mar 3, 2022 · 2 comments
Closed

Comments

@AaronC81
Copy link

AaronC81 commented Mar 3, 2022

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

@matz matz closed this as completed in 85c347c Mar 3, 2022
@AaronC81
Copy link
Author

AaronC81 commented Mar 3, 2022

Thank you for the quick fix!

@matz
Copy link
Member

matz commented Mar 3, 2022

Sorry for the silly mistake.

mimaki pushed a commit to mruby-Forum/mruby that referenced this issue Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants