steep icon indicating copy to clipboard operation
steep copied to clipboard

Steep cannot detect the type of the `rescue =>` variable after they leak scope in Ruby

Open ParadoxV5 opened this issue 2 years ago • 1 comments

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

ParadoxV5 avatar Oct 01 '23 01:10 ParadoxV5

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

ParadoxV5 avatar Oct 01 '23 02:10 ParadoxV5