Reputation: 123
I'm trying to add RBS information to a ruby gem and am wondering if there is a way to make this work. Take this code:
def some_method(&block)
if block
foo = block.call
end
end
and this signature:
def some_method: () ?{ () -> String } -> void
When I run it through steep check
I get an error message like this:
[error] Type `nil` does not have method `call`
│ Diagnostic ID: Ruby::NoMethod
│
└ foo = block.call
~~~~
Is there a good way to resolve this? I need &block
to be optional, and at that point in the code I already know block
can't be nil, but I don't know how tell RBS about that.
EDIT:
I know I could just change the code to be foo = block&.call
but ideally I'd like to be able to keep the code the same.
Upvotes: 0
Views: 91