Unexpected type error with typo'd integer literal

Consider this example code:

let a: [(String, String, Int)] = [("foo", "bar", 1s)]

This obviously gives the following error:

error: 's' is not a valid digit in integer literal

However, it also gives an unexpected second error:

error: cannot convert value of type '(String, String)' to expected element type '(String, String, Int)'

Why is it ignoring the third tuple element?

2 Likes

This can also create 1-element labelled tuples, which aren't supposed to exist in Swift:

let x: [(s: String, i: Int)] = [(s: "foo", i: 1s)]

cannot convert value of type '(s: String)' to expected element type '(s: String, i: Int)'

1 Like