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

rbs/test: stack level too deep when having super call #478

Closed
palkan opened this issue Nov 19, 2020 · 1 comment
Closed

rbs/test: stack level too deep when having super call #478

palkan opened this issue Nov 19, 2020 · 1 comment
Assignees
Milestone

Comments

@palkan
Copy link
Contributor

palkan commented Nov 19, 2020

Due to the usage of the alias method chain approach (

def self.setup_alias_method_chain(klass, target)
), invoking super from a method causes stack level too deep in case both parent and child classes have signatures defined for the method.

Example:

# a.rb
class A
  def foo
    "bar"
  end
end

class B < A
  def foo
    super.size
  end
end

p B.new.foo

# sig/a.rbs
class A
  def foo: () -> String
end

class B < A
  def foo: () -> Integer
end

Run:

$ RBS_TEST_TARGET='A,B' ruby -r rbs/test/setup a.rb

I, [2020-11-19T09:41:59.154893 #177]  INFO -- : Setting up hooks for ::A
I, [2020-11-19T09:41:59.155009 #177]  INFO -- rbs: Installing runtime type checker in A...
I, [2020-11-19T09:41:59.162527 #177]  INFO -- rbs: Setting up method hook in #foo...
I, [2020-11-19T09:41:59.166309 #177]  INFO -- : Setting up hooks for ::B
I, [2020-11-19T09:41:59.166368 #177]  INFO -- rbs: Installing runtime type checker in B...
I, [2020-11-19T09:41:59.167210 #177]  INFO -- rbs: Setting up method hook in #foo...
/usr/local/lib/ruby/gems/3.0.0/gems/rbs-0.17.0/lib/rbs/test/type_check.rb:74:in `args': stack level too deep (SystemStackError)
        from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-0.17.0/lib/rbs/test/type_check.rb:46:in `method_call'
        from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-0.17.0/lib/rbs/test/type_check.rb:23:in `block in overloaded_call'
        from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-0.17.0/lib/rbs/test/type_check.rb:22:in `map'
        from /usr/local/lib/ruby/gems/3.0.0/gems/rbs-0.17.0/lib/rbs/test/type_check.rb:22:in `overloaded_call'
@palkan palkan changed the title stack level too deep when having super call rbs/test: stack level too deep when having super call Nov 19, 2020
@soutaro soutaro self-assigned this Nov 23, 2020
@soutaro soutaro added this to the Ruby 3.0 milestone Nov 23, 2020
@soutaro
Copy link
Member

soutaro commented Nov 27, 2020

I believe this is fixed in #489.

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

No branches or pull requests

2 participants