-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[SR-8213] Compiler may indicate "case will never be executed" even if it is unavoidable to execute the case in switch statement. #50745
Comments
@xedin, think this one's easy enough to be a StarterBug? You'd have to do some checking about whether a pattern was the only one in the case… |
I think it makes sense to mark it as a StarterBug, it seems like that could be checked when cases are projected... |
Sure, go ahead, @vguerra! |
Resetting assignee for all Starter Bugs not touched since 2018. |
Maybe @LucianoPAlmeida is working on this, otherwise please feel free to take it over! |
I'm not working on this so go-ahead Gabriel Igliozzi (JIRA User) 🙂 |
Comment by Gabriel Igliozzi (JIRA) Hey @LucianoPAlmeida thanks for the response, I just did an pull on the master branch, compiled and ran that test code (with the swiftc command) and got test.swift:11:3: warning: case will never be executed
case (.a, _), (_, .a): print("e0 or e1 is .a") // -> warning: case will never be executed
^ Is this a valid way to test the master branch?, if so I believe the error is not yet resolved. |
Seems like the problem is still here, normally a quick and easy way to test if an issue is reproducible on master is with https://swift.godbolt.org there you can find the latest nightly snapshot from the master, but of course, you can download the lastest snapshot or build master locally and create a new file with the code as a test case and run it using lit 🙂 |
Should this issue be closed? In the current version of swift, no warnings are produced. Added a test case in #65819 to verify. |
The warning itself was not a bug. It means that the second pattern will never be matched because a previous one always matches, which is true for |
@AnthonyLatsis Thank you for explaining! |
Environment
OS: macOS, Ubuntu 16.04
Swift: 4.1.2, 4.2-DEVELOPMENT-SNAPSHOT-2018-07-08
Additional Detail from JIRA
md5: df5f44ab5b8a1d3c8ee6ed4a803d858c
is duplicated by:
Issue Description:
(As I commented on SR-8208,)
The compiler shows a wrong warning, when the following code is compiled:
Consideration
case will be always executed
(_, .a) will never match
The text was updated successfully, but these errors were encountered: