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 does not support %a{implicitly-returns-nil} annotation #1251

Closed
tk0miya opened this issue Oct 3, 2024 · 3 comments
Closed

Steep does not support %a{implicitly-returns-nil} annotation #1251

tk0miya opened this issue Oct 3, 2024 · 3 comments

Comments

@tk0miya
Copy link
Contributor

tk0miya commented Oct 3, 2024

Since RBS-3.6, some core methods have been annotated as %a{implicitly-returns-nil} and do not return nil in type definitions (see ruby/rbs#1921).

However Steep does not support the annotation. So it emits unexpected warnings to users.

For example, Steep emits UnreachableBranch for the following code:

item = [1, 2, 3].first

if item
  puts "Item is #{item}"
else
  puts "Item is nil"
end

Result:

$ bundle exec steep check --severity=information
# Type checking files:

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

app/app.rb:5:0: [information] The branch is unreachable
│ Diagnostic ID: Ruby::UnreachableBranch
│
└ else
  ~~~~

Detected 1 problem from 1 file

Steepfile:

D = Steep::Diagnostic

target :app do
  signature "sig"
  check "app"

  configure_code_diagnostics(D::Ruby.strict)
end

Environment:

  • Steep 1.7.1 or 1.8.0
  • RBS 3.6.1

The warning is not emitted with RBS-3.5.3.

$ bundle exec steep check --severity=information
# Type checking files:

..........................................................................................................................................................................................................................................................................................

No type error detected. 🫖
@nickjer
Copy link

nickjer commented Oct 8, 2024

Looks like this is related to the PR: #1258

@soutaro
Copy link
Owner

soutaro commented Oct 8, 2024

Yes. I think this is done with #1258.

@tk0miya
Copy link
Contributor Author

tk0miya commented Oct 8, 2024

Thanks!

@tk0miya tk0miya closed this as completed Oct 8, 2024
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

3 participants