Inconsistencies around Method / block / Proc
Open
@soutaro is already working on this.
Since Aug 13, 2021.
steep
- Dominant language
- Ruby
- Stars
- 2.2k
- Forks
- 256
- Avg merge
- 6d 17h
- Merged PRs (30d)
- 37
Description
I'm getting a few issues in steep which might be directly related to rbs. Take the following example into account:
# rbs
class A
EX: ^(String name) -> bool
def each: () { (String) -> void } -> void
| () -> Enumerable[String]
end
class B
def initialize: (^(String) -> void) -> untyped
end
I get the following errors for the following code:
# given an instance of A
def bla(str)
puts str
end
a.each(&method(:bla))
# steep error: Cannot pass a value of type `::Method` as a block-pass-argument of type `^(...
class A
CHECK_IF_IP = Proc.new { |x| }
# steep error: Cannot assign a value of type `::Proc` to a constant of type `^(::String) -> bool`
# ::Proc <: ^(::String) -> bool(Ruby::IncompatibleAssignment)
#
# this goes away when I redefine with ->(x) ...
def each(&block)
B.new(block)
# steep error: Cannot pass a value of type `(^(::String) -> void | nil)` as an argument of type `^(::String) -> void`
# (^(::String) -> void | nil) <: ^(::String) -> void
# nil <: ^(::String) -> void(Ruby::ArgumentTypeMismatch)
block["bla"]
# steep error: Type `(^(::String) -> void | nil)` does not have method `[]`(Ruby::NoMethod)
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.
Assessment
This issue has not been assessed yet.