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

super args not handled correctly in some cases #78

Open
davebytemfg opened this issue Apr 30, 2021 · 0 comments
Open

super args not handled correctly in some cases #78

davebytemfg opened this issue Apr 30, 2021 · 0 comments

Comments

@davebytemfg
Copy link

$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
$ ruby mygame/app/main.rb 
Super Bad:4 5 6
Super Good:4 5 6

# this was on 2.11 
$ ./dragonruby 
** INFO: =app/main.rb= queued to load via ~require~. (-1, -1)
Super Bad:4 2 3
Super Good:4 5 6

using this source

class Parent
  def foo(a=1, b: 2, c:3)
    "#{a} #{b} #{c}"
  end

  def foo2(a=1, b: 2, c:3)
    "#{a} #{b} #{c}"
  end
end

class Child < Parent
  def foo(a=1, b: 2, c:3)
    super
  end

  def foo2(a=1, b: 2, c:3)
    super(a, b:b, c:c)
  end
end

puts "Super Bad:" + Child.new.foo(4, b:5, c:6)
puts "Super Good:" + Child.new.foo2(4, b:5, c:6)

def tick a
end

https://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/syntax.html#super

https://medium.com/rubycademy/the-super-keyword-a75b67f46f05#:~:text=When%20a%20method%20with%20arguments,method%20to%20the%20parent%20method.&text=Here%20the%20Child%20class%20inherits%20from%20the%20Parent%20class.

I ran into this when building a subclass off of https://github.com/danhealy/dragonruby-zif/blob/16b5b2daebe30b0aaf5684e285f2bdd3879e349b/app/lib/zif/ui/label.rb#L55 and the initialize method had a ton of arguments that I initially didn't pass to super

Easy work around, but took some time to figure out why the font wasn't getting rendered right.

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

1 participant