Skip to content

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

Merged
soutaro merged 1 commit intomasterfrom
or-nil-typing
Jul 14, 2023
Merged

Give an optional type hint to lhs of ||#874
soutaro merged 1 commit intomasterfrom
or-nil-typing

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
@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.

1 participant