Swift grammar summary has incorrect

Originator:weissismail
Number:rdar://18481484 Date Originated:28 Sep 2014
Status:Closed Resolved:12 Jan 2015
Product:Swift Documentation Product Version:
Classification:Serious Bug Reproducible:n/a
 
The published Swift grammar summary [1] has incorrect "if" condition rules. Xcode doesn't compile programs that can be produced using the grammar. For example:

With the following productions:

if-statement → if ­if-condition ­code-block ­else-clause­_opt
if-condition → expression­  declaration­
declaration → import-declaration­
import-declaration → attributes­_opt­ import­ import-kind­_opt­ import-path­

I can produce the following illegal programs (which Xcode rightly detects as illegal):

if import Foundation {}

or with similar rules

if class {} {}

and other illegal programs.

It seems that the "declaration" bit of the if-condition is misplaced. Only expressions and let bindings should be allowed I think.

[1]: https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/zzSummaryOfTheGrammar.html

Comments

Johannes Weiß18-Jan-2015 00:15 AM

This issue has been verified as resolved and can be closed.

By weissismail at Jan. 18, 2015, 12:17 a.m. (reply...)

Apple Developer Relations12-Jan-2015 06:48 PM

This is ready to verify:

https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/doc/uid/TP40014097-CH33-ID434

It now reads:

if-condition --> expression | value-binding-pattern

Please let us know whether the issue is resolved for you by updating your bug report.

By weissismail at Jan. 18, 2015, 12:17 a.m. (reply...)

Johannes Weiß13-Dec-2014 00:23 AM

From everything I can see there hasn't been anything changed around the described problem. The illegal program

if import Foundation {}

can still be produced from the grammar.

By weissismail at Jan. 18, 2015, 12:17 a.m. (reply...)

Apple Developer Relations12-Dec-2014 05:00 PM

The fix is live in the iOS Pre-Release DevLib. Please verify here: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html

Please let us know whether the issue is resolved for you by updating your bug report.

By weissismail at Jan. 18, 2015, 12:17 a.m. (reply...)

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!