Wednesday, June 27, 2018

SR-7380, Ambiguous KeyPath

Matt Diephouse:

Here’s the bug I fixed (with a lot of help):

7380.swift:1:16: error: type of expression is ambiguous without more context
"str"[keyPath: \.count]
               ^~~~~~~

That seems obviously broken. The value is a String literal. They KeyPath should obviously be String.count. So why doesn’t this work?

This is an interesting look at learning how to fix a bug in the Swift compiler.

Comments RSS · Twitter

Leave a Comment