steep
steep copied to clipboard
Steep cannot detect the type of the `rescue =>` variable after they leak scope in Ruby
ruby.rb:
begin
0/0
rescue StandardError => e
# fall-through
end
p e
ruby ruby.rb:
#<ZeroDivisionError: divided by 0>
steep check with strict diagnostic:
# Type checking files:
...................................................................................F
ruby.rb:7:2: [warning] Cannot detect the type of the expression
│ Diagnostic ID: Ruby::FallbackAny
│
└ p e
~
Detected 1 problem from 1 file
begin
0/0
rescue StandardError => e
a = e
end
p a
check with all_error diagnostic:
# Type checking files:
....................................................................................
No type error detected. 🍵
begin
0/0
rescue StandardError => e
a = e
end
raise a
check with default diagnostic:
# Type checking files:
...................................................................................F
ruby.rb:7:0: [error] Cannot find compatible overloading of method `raise` of type `::Object`
│ Method types:
│ def raise: () -> bot
│ | (::string, ?cause: (::Exception | nil)) -> bot
│ | (::_Exception, ?(::_ToS | nil), ?(nil | ::String | ::Array[::String]), ?cause: (::Exception | nil)) -> bot
│
│ Diagnostic ID: Ruby::UnresolvedOverloading
│
└ raise a
~~~~~~~
Detected 1 problem from 1 file