You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
then the following method presents a steep type error:
def each(&)
return enum_for(__method__) unless block_given?
@bag_of_ints.each(&)
# Cannot pass a value of type `(^(::Integer) -> void | nil)` as a block-pass-argument of type `^(::Integer) -> void`
# (^(::Integer) -> void | nil) <: ^(::Integer) -> void
# nil <: ^(::Integer) -> void(Ruby::BlockTypeMismatch)
because the block_given? call isn't narrowing the type.
The error goes away if I defined the function with (&blk) and do unless blk instead. However, rubocop will enforce nameless blocks in autocorrect for modern ruby, which exposes this error on ruby upgrades.
The text was updated successfully, but these errors were encountered:
If I have the following:
then the following method presents a steep type error:
because the block_given? call isn't narrowing the type.
The error goes away if I defined the function with
(&blk)
and dounless blk
instead. However, rubocop will enforce nameless blocks in autocorrect for modern ruby, which exposes this error on ruby upgrades.The text was updated successfully, but these errors were encountered: