Swift Regret: Subscript Trailing Closures
Swift regret: subscript trailing closures.
— Jordan Rose (@UINT_MIN) September 17, 2021
Wait, what?https://t.co/1dlBAS9gRS
Part of the Swift Regrets series.
Wait, “subscript trailing closures”? What? Well…take a look at SR-6157.
Remember how I said subscript indexes have all the fancy features of function arguments? We implemented that by having them share code in the parser, where calls look for ()
and subscripts for []
. And we forgot to turn off the trailing closure part for subscripts. That’s it.
I think everything else on this list so far has been a case where I wish we made a different decision about something. But there was no decision here. It’s a bug that turned into a compatibility issue that wasn’t important enough to deprecate/error on.