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

emit UnreachableBranch to the "void" condition #1356

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

tk0miya
Copy link
Contributor

@tk0miya tk0miya commented Nov 25, 2024

It would be better to emit UnreachableBranch diagnostics to use "void" variables for if-conditions.

@@ -2983,6 +2983,75 @@ def test_if_annotation_success
end
end

def test_unreachable_if_void
Copy link
Owner

Choose a reason for hiding this comment

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

Please move these tests to type_check_test.rb if you can.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -409,6 +409,8 @@ def partition_union(type)
]
when AST::Types::Any, AST::Types::Boolean, AST::Types::Top, AST::Types::Logic::Base
[type, type]
when AST::Types::Bot, AST::Types::Void
Copy link
Owner

Choose a reason for hiding this comment

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

👍

@soutaro soutaro added this to the Steep 1.9 milestone Nov 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
It would be better to emit UnreachableBranch diagnostics to use "void"
variables for if-conditions.
@tk0miya tk0miya force-pushed the emit_UnreachableBranch_to_void branch from 51b631b to 1f0c1ef Compare November 26, 2024 11:37
Copy link
Owner

@soutaro soutaro left a comment

Choose a reason for hiding this comment

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

🙏

@soutaro soutaro merged commit 4fb0d01 into soutaro:master Nov 29, 2024
17 checks passed
@tk0miya tk0miya deleted the emit_UnreachableBranch_to_void branch November 29, 2024 14:01
@soutaro soutaro added the Released The PR is already included in a published release label Dec 6, 2024
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

2 participants