[Pitch] One-Element Tuples

Late to the party as I haven't seen this topic before. I love this pitch, big +1 from me! It would streamline the language logic IRT the current differences between pretty much non-existing "single-element tuples" and normal tuples.

Examples of differences between single-element tuples and normal tuples I brought up in another thread:

var xy: (Int, Int) = (0, 0)
xy.0 = 1 // ✅
var x: (_: Int) = (_: 0)
x.0 = 1  // 🛑
print(type(of: ())) // ()
print(type(of: 1)) // Int
print(type(of: (_:1))) // Int
print(type(of: (1, 2))) // (Int, Int)
print(1 is any Equatable)       // true
print((_: 1) is any Equatable)  // true
print(() is any Equatable)      // false
print((2, 2) is any Equatable)  // false
var x: (Int, Int) = (1, 2) // ✅
var x: (Int, Int) = 1, 2   // 🛑
var x: (_: Int) = (_:1)    // ✅
var x: (_: Int) = 1        // ✅
let xy = (x: 0, y: 0)      // ✅
let x = (x: 0)             // 🛑 Cannot create a single-element tuple with an element label
struct S: Codable { var x = (0, 0) } // 🛑
struct S: Codable { var x = () }     // 🛑
struct S: Codable { var x = (_:0) }  // ✅
print(Mirror(reflecting: ()).displayStyle)     // Optional<tuple>
print(Mirror(reflecting: (0, 0)).displayStyle) // Optional<tuple>
print(Mirror(reflecting: (_:0)).displayStyle)  // nil
1 Like