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

[SR-226] Implement warning about the use of C-style for loops in Swift 2.2 #42848

Closed
DougGregor opened this issue Dec 14, 2015 · 3 comments
Closed
Assignees
Labels
compiler The Swift compiler in itself task

Comments

@DougGregor
Copy link
Member

Previous ID SR-226
Radar None
Original Reporter @DougGregor
Type Task
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Task
Assignee @gregomni
Priority Medium

md5: 059d6db82e39ab1b799b6c27509640a5

Issue Description:

Per

https://github.com/apple/swift-evolution/blob/master/proposals/0007-remove-c-style-for-loops.md

we should implement a warning in Swift 2.2 that informs users that C-style for loops are going away.

@DougGregor
Copy link
Member Author

Bonus points for recognizing idiomatic C-style for loops that could trivially be rewritten as for-in loops and providing a Fix-It to help with migration. For example:

for var x = 0; x != n; ++x { ... }

could be migrated to:

for x in 0..n { ... }

when x isn't written to.

@gregomni
Copy link
Collaborator

I've been doing some diagnoses fixing recently and getting somewhat familiar with this area. Would be happy to take this on, if no one else has code in the works.

@gregomni
Copy link
Collaborator

Still need to clean up the fix it ranges, but here's most of it: <https://github.com/apple/swift/pull/552\>.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself task
Projects
None yet
Development

No branches or pull requests

2 participants