File tree Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Expand file tree Collapse file tree 2 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -2473,7 +2473,9 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
2473
2473
else {}
2474
2474
}
2475
2475
right_sym := g.table.get_type_symbol (g.unwrap_generic (val_type))
2476
- is_fixed_array_var := right_sym.kind == .array_fixed && val is ast.Ident
2476
+ is_fixed_array_var := right_sym.kind == .array_fixed && (val is ast.Ident
2477
+ || val is ast.IndexExpr || val is ast.CallExpr
2478
+ || val is ast.SelectorExpr )
2477
2479
g.is_assign_lhs = true
2478
2480
g.assign_op = assign_stmt.op
2479
2481
if val_type.has_flag (.optional) {
@@ -2490,7 +2492,8 @@ fn (mut g Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) {
2490
2492
g.expr (val)
2491
2493
g.writeln (';}' )
2492
2494
}
2493
- } else if assign_stmt.op == .assign && (is_fixed_array_init || is_fixed_array_var) {
2495
+ } else if assign_stmt.op == .assign
2496
+ && (is_fixed_array_init || (right_sym.kind == .array_fixed && val is ast.Ident )) {
2494
2497
mut v_var := ''
2495
2498
arr_typ := styp.trim ('*' )
2496
2499
if is_fixed_array_init {
Original file line number Diff line number Diff line change
1
+ fn test_assign_map_value_of_fixed_array () {
2
+ mut m := map [string ][2 ]f64 {}
3
+
4
+ m['A' ] = [1.1 , 2.2 ]!
5
+ m['B' ] = [0.1 , 0.2 ]!
6
+
7
+ mut arr := m['A' ]
8
+ println (arr)
9
+ assert '$arr ' == '[1.1, 2.2]'
10
+
11
+ arr = m['B' ]
12
+ println (arr)
13
+ assert '$arr ' == '[0.1, 0.2]'
14
+
15
+ arr = m['C' ]
16
+ println (arr)
17
+ assert '$arr ' == '[0, 0]'
18
+ }
You can’t perform that action at this time.
0 commit comments