You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kp(\.count) // expected-error {{key path root inferred as optional type 'String?' must be unwrapped to refer to member 'count' of unwrapped type 'String'}}
1011
-
// expected-note@-1 {{chain the optional using '?.' to access unwrapped type member 'count'}} {{8-8=?.}}
1012
-
// expected-note@-2 {{unwrap the optional using '!.' to access unwrapped type member 'count'}} {{8-8=!.}}
1013
1013
let _ :KeyPath<String?,Int>= \.count // expected-error {{key path root inferred as optional type 'String?' must be unwrapped to refer to member 'count' of unwrapped type 'String'}}
1014
-
// expected-note@-1 {{chain the optional using '?.' to access unwrapped type member 'count'}} {{37-37=?.}}
1015
-
// expected-note@-2 {{unwrap the optional using '!.' to access unwrapped type member 'count'}} {{37-37=!.}}
1016
1014
1017
1015
let _ :KeyPath<String?,Int>= \.utf8.count
1018
1016
// expected-error@-1 {{key path root inferred as optional type 'String?' must be unwrapped to refer to member 'utf8' of unwrapped type 'String'}}
1019
-
// expected-note@-2 {{chain the optional using '?.' to access unwrapped type member 'utf8'}} {{37-37=?.}}
1020
-
// expected-note@-3 {{unwrap the optional using '!.' to access unwrapped type member 'utf8'}} {{37-37=!.}}
1021
1017
}
1022
1018
1023
1019
func testSyntaxErrors(){
@@ -1067,8 +1063,9 @@ func f_56996() {
1067
1063
// https://github.com/apple/swift/issues/55805
1068
1064
// Key-path missing optional crashes compiler: Inactive constraints left over?
1069
1065
func f_55805(){
1070
-
let _:KeyPath<String?,Int?>= \.utf8.count // expected-error {{value of optional type 'String.UTF8View?' must be unwrapped to refer to member 'count' of wrapped base type 'String.UTF8View'}}
1071
-
// expected-note@-1 {{chain the optional using '?' to access member 'count' only for non-'nil' base values}}
1066
+
let _:KeyPath<String?,Int?>= \.utf8.count
1067
+
// expected-error@-1 {{key path root inferred as optional type 'String?' must be unwrapped to refer to member 'utf8' of unwrapped type 'String'}}
1068
+
// expected-error@-2 {{key path value type 'Int' cannot be converted to contextual type 'Int?'}}
1072
1069
}
1073
1070
1074
1071
// rdar://74711236 - crash due to incorrect member access in key path
0 commit comments