Confused by key path's grammer in Swift Reference

I am reading the syntax definition of key path in Swift Reference - key-path-expression.

key-path-expression → \ type_opt . key-path-components

In this definition, it is easy to see that a key path contains at least one dot character ., but

\[Int][0]

is legal, why?

1 Like

Seems like a bug to me at a glance, worth reporting over on Feedback Assistant.

If I remember correctly, we wrote this part of the grammar before keypaths supported subscripts; seems plausible that we missed this formulation when going back to update it.

3 Likes
Terms of Service

Privacy Policy

Cookie Policy