@@ -85,28 +85,24 @@ var _: [Float: Int] = [1] // expected-error {{dictionary of type '[Float : Int]'
8585
8686var _: [ Int : Int ] = [ " foo " ] // expected-error {{dictionary of type '[Int : Int]' cannot be initialized with array literal}}
8787// 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'}}
8988
9089var _ = useDictStringInt ( [ " Key " ] ) // expected-error {{dictionary of type 'DictStringInt' cannot be used with array literal}}
9190// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{32-32=: <#value#>}}
9291
9392var _ = useDictStringInt ( [ 4 ] ) // expected-error {{dictionary of type 'DictStringInt' cannot be used with array literal}}
9493// 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')}}
9694
9795var _: [ [ Int : Int ] ] = [ [ 5 ] ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
9896// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{26-26=: <#value#>}}
9997
10098var _: [ [ Int : Int ] ] = [ [ " bar " ] ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
10199// 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'}}
103100
104101assignDict = [ 1 ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
105102// expected-note@-1 {{did you mean to use a dictionary literal instead?}} {{16-16=: <#value#>}}
106103
107104assignDict = [ " " ] // expected-error {{dictionary of type '[Int : Int]' cannot be used with array literal}}
108105// 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'}}
110106
111107func arrayLiteralDictionaryMismatch< T> ( a: inout T ) where T: ExpressibleByDictionaryLiteral , T. Key == Int , T. Value == Int {
112108 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
116112
117113 a = [ " " ] // expected-error {{dictionary of type 'T' cannot be used with array literal}}
118114 // 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'}}
120115}
121116
122117
@@ -167,3 +162,33 @@ func rdar32330004_2() -> [String: Any] {
167162 // expected-error@-1 {{dictionary of type '[String : Any]' cannot be used with array literal}}
168163 // expected-note@-2 {{did you mean to use a dictionary literal instead?}} {{14-15=:}} {{24-25=:}} {{34-35=:}} {{46-47=:}}
169164}
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