Swift grammar summary has incorrect "for ... in" loop rules
| Originator: | weissismail | ||
| Number: | rdar://18478179 | Date Originated: | 27 Sep 2014 |
| Status: | Open | Resolved: | |
| Product: | Swift | Product Version: | |
| Classification: | Reproducible: | n/a |
Summary:
The published Swift grammar summary [1] has incorrect "for ... in" loop rules. Xcode doesn't compile programs that can be produced using the grammar. For example:
With the following productions:
for-in-statement → for pattern in expression code-block
pattern → value-binding-pattern
value-binding-pattern → var pattern | let pattern
I can produce the following illegal programs (which Xcode rightly detects as illegal):
for var () in [] {}
The for-in loop doesn't accept a "value-binding-pattern".
On top, the "value-binding-pattern" shouldn't be recursive because that would make even less sense:
for var let var let var let () in [] {}
[1]: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/zzSummaryOfTheGrammar.html
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!