[RBS::Test] Cannot call `super` in block
Open
Nobody has claimed this yet.
bug
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
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>'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the handler.rb reproduction and the failing path reported at lib/rbs/test/hook.rb:113, focusing on how RBS::Test invokes the handler block. Run the example with the supplied RBS_TEST setup and confirm that super() works as it does without the checker, including the real aws-sdk-ruby handler_builder_spec.rb case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100