Are these errors caused by a known compiler bug (in Xcode 10):
infix operator |||
prefix operator <<<
postfix operator >>>
func |||(lhs: (Int, Int), rhs: (Int, Int)) -> Void { print("infix") }
prefix func <<<(rhs: (Int, Int)) -> Void { print("prefix") }
postfix func >>>(lhs: (Int, Int)) -> Void { print("postfix") }
(1, 2) ||| (3, 4) // Prints "infix"
<<<(1, 2) // ERROR: '<<<' is not a prefix unary operator
(1, 2)>>> // ERROR: '>>>' is not a postfix unary operator
?
Note that all three works as expected when called in "function form":
(|||)((1, 2), (3, 4)) // Prints "infix"
(<<<)((1, 2)) // Prints "prefix"
(>>>)((1, 2)) // Prints "postfix"
Further details here.
All three work if the parameter type is not a tuple type:
infix operator |||
prefix operator <<<
postfix operator >>>
func |||(lhs: Int, rhs: Int) -> Void { print("infix") }
prefix func <<<(rhs: Int) -> Void { print("prefix") }
postfix func >>>(lhs: Int) -> Void { print("postfix") }
1 ||| 2 // Prints "infix"
<<<3 // Prints "prefix"
4>>> // Prints "postfix"
(1) ||| (2) // Prints "infix"
<<<(3) // Prints "prefix"
(4)>>> // Prints "postfix"
(|||)(1, 2) // Prints "infix"
(<<<)(3) // Prints "prefix"
(>>>)(4) // Prints "postfix"
All three work with any type (including tuple types) if the parameter is generic:
infix operator |||
prefix operator <<<
postfix operator >>>
func |||<T>(lhs: T, rhs: T) -> Void { print("infix") }
prefix func <<<<T>(rhs: T) -> Void { print("prefix") }
postfix func >>><T>(lhs: T) -> Void { print("postfix") }
1 ||| 2 // Prints "infix"
<<<3 // Prints "prefix"
4>>> // Prints "postfix"
(1, 2) ||| (3, 4) // Prints "infix"
<<<(5, 6) // Prints "prefix"
(7, 8)>>> // Prints "postfix"