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] Cannot call super in block #1716

Open
ksss opened this issue Jan 10, 2024 · 0 comments
Open

[RBS::Test] Cannot call super in block #1716

ksss opened this issue Jan 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ksss
Copy link
Collaborator

ksss commented Jan 10, 2024

I have found a case where test fails to call super in a block during RBS::Test execution.

Repro:

#! /usr/bin/env ruby

class Super
  def call
    'super'
  end
end

class Sample
  def initialize
    @handlers = []
  end

  def handler(&block)
    @handlers << Class.new(Super) { define_method(:call, &block) }
  end

  def call
    @handlers.map { |h| h.new.call }
  end
end

sample = Sample.new
sample.handler do
  p super()
end
sample.call
# handler.rbs
class Sample
  def handler: () { () -> void } -> void
end
$ ruby handler.rb
"super"
$ RUBYOPT="-r rbs/test/setup" RBS_TEST_OPT="-I handler.rbs" RBS_TEST_TARGET="Sample" ruby handler.rb
I, [2024-01-10T16:01:48.008226 #87538]  INFO -- : Setting up hooks for ::Sample
I, [2024-01-10T16:01:48.008271 #87538]  INFO -- rbs: Installing runtime type checker in Sample...
I, [2024-01-10T16:01:48.011547 #87538]  INFO -- rbs: Setting up method hook in #handler...
handler.rb:25:in `block in <main>': super called outside of method (NoMethodError)
	from /Users/ksss.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/rbs-3.4.0/lib/rbs/test/hook.rb:113:in `instance_exec'
	from /Users/ksss/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/rbs-3.4.0/lib/rbs/test/hook.rb:113:in `block in handler__with__RBS_TEST_20215d_84415718'
	from handler.rb:19:in `block in call'
	from handler.rb:19:in `map'
	from handler.rb:19:in `call'
	from handler.rb:27:in `<main>'

Real case: https://github.com/aws/aws-sdk-ruby/blob/b501a7f87aaf78f12667de2c436f4f6463fe6af9/gems/aws-sdk-core/spec/seahorse/client/handler_builder_spec.rb#L52-L55

@soutaro soutaro added the bug Something isn't working label Jan 11, 2024
@soutaro soutaro added this to the RBS 3.5 milestone Jan 11, 2024
@soutaro soutaro removed this from the RBS 3.5 milestone Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants