@@ -85,28 +85,24 @@ var _: [Float: Int] = [1] // expected-error {{dictionary of type '[Float : Int]'
85
85
86
86
var _: [ Int : Int ] = [ " foo " ] // expected-error {{dictionary of type '[Int : Int]' cannot be initialized with array literal}}
87
87
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{27-27=: <#value#>}}
88
- // expected-error@-2 {{cannot convert value of type 'String' to expected dictionary key type 'Int'}}
89
88
90
89
var _ = useDictStringInt ( [ " Key " ] ) // expected-error {{dictionary of type 'DictStringInt' cannot be used with array literal}}
91
90
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{32-32=: <#value#>}}
92
91
93
92
var _ = useDictStringInt ( [ 4 ] ) // expected-error {{dictionary of type 'DictStringInt' cannot be used with array literal}}
94
93
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{28-28=: <#value#>}}
95
- // expected-error@-2 {{cannot convert value of type 'Int' to expected dictionary key type 'DictStringInt.Key' (aka 'String')}}
96
94
97
95
var _: [ [ Int : Int ] ] = [ [ 5 ] ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
98
96
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{26-26=: <#value#>}}
99
97
100
98
var _: [ [ Int : Int ] ] = [ [ " bar " ] ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
101
99
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{30-30=: <#value#>}}
102
- // expected-error@-2 {{cannot convert value of type 'String' to expected dictionary key type 'Int'}}
103
100
104
101
assignDict = [ 1 ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
105
102
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{16-16=: <#value#>}}
106
103
107
104
assignDict = [ " " ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
108
105
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{17-17=: <#value#>}}
109
- // expected-error@-2 {{cannot convert value of type 'String' to expected dictionary key type 'Int'}}
110
106
111
107
func arrayLiteralDictionaryMismatch< T> ( a: inout T ) where T: ExpressibleByDictionaryLiteral , T. Key == Int , T. Value == Int {
112
108
a = [ ] // expected-error {{use [:] to get an empty dictionary literal}} {{8-8=:}}
@@ -116,7 +112,6 @@ func arrayLiteralDictionaryMismatch<T>(a: inout T) where T: ExpressibleByDiction
116
112
117
113
a = [ " " ] // expected-error {{dictionary of type 'T' cannot be used with array literal}}
118
114
// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{10-10=: <#value#>}}
119
- // expected-error@-2 {{cannot convert value of type 'String' to expected dictionary key type 'Int'}}
120
115
}
121
116
122
117
@@ -167,3 +162,33 @@ func rdar32330004_2() -> [String: Any] {
167
162
// expected-error@-1 {{dictionary of type '[String : Any]' cannot be used with array literal}}
168
163
// expected-note@-2 {{did you mean to use a dictionary literal instead?}} {{14-15=:}} {{24-25=:}} {{34-35=:}} {{46-47=:}}
169
164
}
165
+
166
+ // https://github.com/apple/swift/issues/59215
167
+ class S59215 {
168
+ var m : [ String : [ String : String ] ] = [ : ]
169
+ init ( ) {
170
+ m [ " a " ] = [ " " , 1 ] //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
171
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{17-18=:}}
172
+ m [ " a " ] = [ 1 , " " ] //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
173
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{17-18=:}}
174
+ m [ " a " ] = [ " " , " " ] //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
175
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{17-18=:}}
176
+ m [ " a " ] = [ 1 , 1 ] //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
177
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{17-18=:}}
178
+ }
179
+ }
180
+
181
+ func f59215( _ a: [ String : String ] ) { }
182
+ f59215 ( [ " " , 1 ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
183
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}}
184
+ f59215 ( [ 1 , " " ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
185
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}}
186
+ f59215 ( [ 1 , 1 ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
187
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}}
188
+ f59215 ( [ " " , " " ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
189
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}}
190
+
191
+ f59215 ( [ " " , " " , " " , " " ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
192
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}} {{19-20=:}}
193
+ f59215 ( [ " " , " " , " " , " " ] ) //expected-error{{dictionary of type '[String : String]' cannot be used with array literal}}
194
+ // expected-note@-1{{did you mean to use a dictionary literal instead?}} {{11-12=:}} {{19-20=:}}
0 commit comments