mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
23 lines
484 B
Swift
23 lines
484 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// https://github.com/swiftlang/swift/issues/60619
|
|
do {
|
|
protocol P {
|
|
associatedtype A
|
|
}
|
|
struct S {
|
|
subscript<T: P>(_: T) -> T {
|
|
get {} set {}
|
|
}
|
|
}
|
|
|
|
func takesInOut(_: inout any P) {}
|
|
|
|
var s: S
|
|
let p: any P
|
|
|
|
let _ = s[p]
|
|
s[p] = p // expected-error {{cannot assign through subscript: 's' is immutable}}
|
|
takesInOut(&s[p]) // expected-error {{cannot pass immutable value as inout argument: 's' is immutable}}
|
|
}
|