swift-book icon indicating copy to clipboard operation
swift-book copied to clipboard

Error in Grammar of a key-path expression

Open tadbyt opened this issue 1 year ago • 0 comments

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/expressions#Key-Path-Expression

Description

self is mislocated in the grammar. It should be an alternative to identifier as a key-path-component, rather than as a key-path-suffix. This allows self to be a suffix, rather than to require it to be preceded by a dot (period). This affects both the key-path-component and key-path-suffix productions.

Correction

Grammar of a key-path expression

key-path-expression → \ type? . key-path-components key-path-components → key-path-component | key-path-component . key-path-components key-path-component → identifier key-path-postfixes? | self key-path-postfixes? | key-path-postfixes key-path-postfixes → key-path-postfix key-path-postfixes? key-path-postfix → ? | ! | [ function-call-argument-list ]

tadbyt avatar Jan 25 '24 05:01 tadbyt