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

When will fix this bug?

Has it been filed as a bug via the instructions above? If not, it’s unlikely that anyone is going to fix it.

1 Like