Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

steep ignores assignments to variables through local scopes #1231

Open
p-datadog opened this issue Sep 24, 2024 · 0 comments
Open

steep ignores assignments to variables through local scopes #1231

p-datadog opened this issue Sep 24, 2024 · 0 comments

Comments

@p-datadog
Copy link

When a variable is overwritten from a block scope, steep ignores the overwrite. Example:

value = nil

loop do
  value = 1
  break
end

value + 2

puts value

Result:

% be steep check
# Type checking files:

...................................................................................F

test.rb:8:6: [error] Type `nil` does not have method `+`
│ Diagnostic ID: Ruby::NoMethod
│
└ value + 2
        ~

Detected 1 problem from 1 file

The above example is valid Ruby code. Is there a way to not have steep generate an error on it?

A more real-world usage example of the same pattern is Benchmark.realtime:

value = nil
time = Benchmark.realtime do
  value = ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant