override a function with a block fails
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
- rbs: 3.1.3
- ruby: 3.2.2
i'm finding an issue typing the following structure:
class A
def initialize(a, b)
@a = a
@b = b
end
end
class B < A
def initialize(a, b)
super
yield self if block_given?
end
class A
def initialize: (Integer a, String b) -> void
end
class B
def initialize: (Integer a, String b) { (self) -> void } -> void
end
When I use runtime type-checking via rbs test using smth like B.new(1, "a") { |b| puts b }, I get an error similar to:
RuntimeError: Neutered Exception RBS::Test::Tester::TypeError: TypeError: [B#initialize] ArgumentTypeError: expected `String` (b) but given `1`
Where the first argument is being incorrectly passed the second argumet type def.
I can workaround that now by doing the block-based definition on A's rbs file, which is wrong, but it at least fixes it.
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 by reproducing the reported failure with the Ruby and RBS snippets using rbs test. Trace how runtime checking handles an overridden initialize method with a block, then verify that B.new(1, "a") checks the first argument as Integer, the second as String, and the block without swapping types.
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
- 35/100