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

Give an optional type hint to lhs of || #874

Merged
merged 1 commit into from
Jul 14, 2023
Merged

Give an optional type hint to lhs of || #874

merged 1 commit into from
Jul 14, 2023

Conversation

soutaro
Copy link
Owner

@soutaro soutaro commented Jul 14, 2023

No description provided.

@soutaro soutaro added this to the Steep 1.5.x milestone Jul 14, 2023
"a.rb" => <<~RUBY
class Hello
def foo(a)
a&.then {|x| x.infinite? } || -1
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steep reported a confusing type error:

Cannot find compatible overloading of method `then` of type `::Integer`

It was because the hint given to &.then call is Integer, and it is forwarded to block typing where x.infinite? has Integer?.

@soutaro soutaro enabled auto-merge July 14, 2023 06:45
@soutaro soutaro merged commit 76bf03a into master Jul 14, 2023
20 checks passed
@soutaro soutaro deleted the or-nil-typing branch July 14, 2023 07:00
@soutaro soutaro added the Released The PR is already included in a published release label Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Released The PR is already included in a published release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant