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

Fix type narrowing on case-when #662

Merged
merged 3 commits into from
Oct 22, 2022
Merged

Fix type narrowing on case-when #662

merged 3 commits into from
Oct 22, 2022

Conversation

soutaro
Copy link
Owner

@soutaro soutaro commented Oct 21, 2022

Add support for the case that more specific class is given to when clause.

# @type var object: Numeric | String
object = ""

case object
when Integer
  object + 1    # Make object be Integer here
else
  object        # object is Numeric | String because the when clause above cannot delete the Numeric case
end

Copy link

@myronmarston myronmarston left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this promptly!

test/type_construction_test.rb Show resolved Hide resolved
@soutaro soutaro merged commit 3c4e59e into master Oct 22, 2022
@soutaro soutaro deleted the fix-type-case-case-when branch October 22, 2022 12:49
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

Successfully merging this pull request may close these issues.

2 participants