swiftlang / swift-book

The Swift Programming Language book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error in Protocol Initializer Declaration text or its grammar

tadbyt opened this issue · comments

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/initialization#Initializer-Inheritance-and-Overriding
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Protocol-Initializer-Declaration
https://docs.swift.org/swift-book/documentation/the-swift-programming-language/declarations#Initializer-Declaration

Description

Either there is an error in the Grammar of a protocol initializer declaration or there is an error in the text of the Protocol Initializer Declaration subsection as they are currently inconsistent. The second sentence in the first paragraph reads:

Protocol initializer declarations have the same form as initializer declarations, except they don’t include the initializer’s body.

The problem is that async is an optional modifier in an initializer declaration, but not for an initializer requirement. Discussion in the Initialize Inheritance and Overriding subsection of the Initialization section does mention asynchronous initializers, so the issue is whether an initializer requirement can specify an asynchronous initializer or not.

Correction

If an initializer requirement can specify an asynchronous initializer, then each of the two protocol-initializer-declaration productions need to have async ? inserted following parameter-clause.

If not, then the aforementioned sentence needs to be modified to:

Protocol initializer declarations have the same form as initializer declarations, except they don’t include the initializer’s body and can't specify an asynchronous initializer.