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-2115] unused variable unreported by compiler #44723
Comments
Comment by erica sadun (JIRA) The compiler should emit a warning / fixit for "i" as it is never used |
I can't remember, but we might have done this deliberately because some people don't like having to write |
Comment by erica sadun (JIRA) Even if deliberate, it still strikes me as wrong. Variable is never used. |
Comment by emlai (JIRA) This seems to have been fixed. I get "Immutable value 'i' was never used; consider replacing with '_' or removing it" for the above code in Swift 3.0.2 preview 1. |
Comment by erica sadun (JIRA) I don't see errors or warnings in Xcode 8.2 beta 2 or in Xcode 8.1 |
Ah, I see the warning if the loop is within a function body, but not at top-level in a script mode file. |
(so it does make sense to treat it as a bug) |
Tagging as StarterBug because it's probably just figuring out the conditions under which this warning is and is not emitted and then changing them. |
Comment by erica sadun (JIRA) When I moved the loop from the global scope of main.swift (maxOS, command line project) into a function, it warned. Should warn at global scope too. |
Comment by Brian (JIRA) VarDeclUsageChecker was only running on AbstractFunctionDecl – I added a check to TopLevelCodeDecl too. |
Comment by Brian (JIRA) Take 2: #7023 |
Comment by Brian (JIRA) This behavior was fixed and should be available in Swift 4.0. |
Additional Detail from JIRA
md5: 9c3041434c2dac44b9c1f658849c7920
Issue Description:
The text was updated successfully, but these errors were encountered: