@@ -2224,7 +2224,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
2224
2224
initializer : & AstStatement ,
2225
2225
) -> Result < BasicValueEnum < ' ink > , Diagnostic > {
2226
2226
let array_value = self . generate_literal_array_value (
2227
- flatten_expression_list ( initializer) ,
2227
+ initializer,
2228
2228
self . get_type_hint_info_for ( initializer) ?,
2229
2229
& initializer. get_location ( ) ,
2230
2230
) ?;
@@ -2238,7 +2238,7 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
2238
2238
/// i16-array-value
2239
2239
fn generate_literal_array_value (
2240
2240
& self ,
2241
- elements : Vec < & AstStatement > ,
2241
+ elements : & AstStatement ,
2242
2242
data_type : & DataTypeInformation ,
2243
2243
location : & SourceRange ,
2244
2244
) -> Result < BasicValueEnum < ' ink > , Diagnostic > {
@@ -2266,6 +2266,23 @@ impl<'ink, 'b> ExpressionCodeGenerator<'ink, 'b> {
2266
2266
) )
2267
2267
} ?;
2268
2268
2269
+ // for arrays of struct we cannot flatten the expression list
2270
+ // to generate the passed structs we need an expression list of assignments
2271
+ // flatten_expression_list will will return a vec of only assignments
2272
+ let elements = if self
2273
+ . index
2274
+ . get_effective_type_or_void_by_name ( inner_type. get_name ( ) )
2275
+ . information
2276
+ . is_struct ( )
2277
+ {
2278
+ match elements {
2279
+ AstStatement :: ExpressionList { expressions, .. } => expressions. iter ( ) . collect ( ) ,
2280
+ _ => unreachable ! ( "This should always be an expression list" ) ,
2281
+ }
2282
+ } else {
2283
+ flatten_expression_list ( elements)
2284
+ } ;
2285
+
2269
2286
let llvm_type = self . llvm_index . get_associated_type ( inner_type. get_name ( ) ) ?;
2270
2287
let mut v = Vec :: new ( ) ;
2271
2288
for e in elements {
0 commit comments