Avatar
Avatar
omochimetaru
@swift-main protocol P<A> { associatedtype A } protocol Q {} struct S<A>: P {} struct K: Q {} func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { (S<K>(), S<K>()) } func usePair<T: Q>(_ pair: (S<T>, S<T>)) {} func main() { let pair = makePair() usePair(pair) }
swiftNightly BOT 5/30/2022 4:38 AM
exit status: 1 with stderr:<stdin>:1:11: error: protocols do not allow generic parameters; use associated types instead protocol P<A> { ^ <stdin>:9:20: error: expected type for function result func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:19: error: consecutive statements on a line must be separated by ';' func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ ; <stdin>:9:23: error: consecutive statements on a line must be separated by ';' func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ ; <stdin>:9:23: error: expected expression func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:50: error: top-level statement cannot begin with a closure expression func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:6: error: expected '{' in body of function declaration func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:20: error: '<' is not a prefix unary operator func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:21: error: cannot find 'T0' in scope func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^~ <stdin>:9:50: error: closure expression is unused func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ <stdin>:9:50: note: did you mean to use a 'do' statement? func makePair() -> <T0: Q, T1: Q> (S<T0>, S<T1>) { ^ do <stdin>:16:9: warning: constant 'pair' inferred to have type '()', which may be unexpected let pair = makePair() ^ <stdin>:16:9: note: add an explicit type annotation to silence this warning let pair = makePair() ^ : () <stdin>:17:5: error: generic parameter 'T' could not be inferred usePair(pa