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

Error in Grammar of an enumeration declaration #265

Open
tadbyt opened this issue Feb 4, 2024 · 0 comments
Open

Error in Grammar of an enumeration declaration #265

tadbyt opened this issue Feb 4, 2024 · 0 comments

Comments

@tadbyt
Copy link
Contributor

tadbyt commented Feb 4, 2024

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Enumeration-Declaration
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/summaryofthegrammar#Declarations

Description

In both instances of the Grammar of an enumeration declaration, the declaration for associated values is given as a tuple-type. The problem is that a tuple-type requires at least two entries and an enumeration case is allowed a single associated value.

Also, there is a conflict between the text in the Enumerations with Cases of a Raw-Value Type and the raw-value-literal production in the grammar. The latter allows a Boolean value, but the former does not allow Bool to be a raw value type. Neither is Bool allowed as a raw value type in the Raw Values subsection of Enumerations in the Language Guide. Per Xcode, Bool is not a valid raw value type.

Correction

Replace the existing union-style-enum-case production with:

union-style-enum-caseenum-case-name associated-values?
associated-values( tuple-type-element-list )

With respect to the second issue, remove boolean-literal as an alternative from the raw-value-literal production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant