[swift-users] Type of expression is ambiguous for static tuples

Rudolf Adamkovič salutis at me.com
Fri Sep 1 05:17:42 CDT 2017


Given the following extension ...

extension Double {
    typealias Triple = (Double, Double, Double)
    static let pythagoreanTriple: Triple = (3, 4, 5)
}
... why does Swift compiler emits the following errors?

// Type of expression is ambiguous without more context
let a: Double = .pythagoreanTriple.0

// Type of expression is ambiguous without more context
func f(_ x: Double) {}
f(.pythagoreanTriple.0)
The errors disappear with explicit Double.pythagoreanTriple.0.

Why doesn't the compiler infer Double in this case?

FYI: Posted also to Stack Overflow here:

https://stackoverflow.com/questions/45998034/type-of-expression-is-ambiguous-for-static-tuples

R+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170901/fdc8ec0d/attachment.html>


More information about the swift-users mailing list