File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -428,10 +428,12 @@ fn test_map_push_directly() {
428428 assert a['aaa' ] == ['a' , 'b' , 'c' ]
429429}
430430
431- fn test_map_push_missing_key_does_not_insert () {
431+ fn test_map_push_inserts_for_missing_key () {
432432 mut a := map [string ][]string {}
433433 a['aaa' ] << 'a'
434- assert a == map [string ][]string {}
434+ assert a == {
435+ 'aaa' : ['a' ]
436+ }
435437}
436438
437439fn test_assign_directly () {
Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) {
567567 }
568568 }
569569 get_and_set_types := val_sym.kind in [.struct , .map , .array, .array_fixed]
570- use_get_and_set := node.is_setter && ! g.inside_map_infix && ! g.inside_left_shift
570+ use_get_and_set := g.inside_left_shift || (node.is_setter && ! g.inside_map_infix)
571571 if g.is_assign_lhs && ! g.is_arraymap_set && ! get_and_set_types {
572572 if g.assign_op == .assign || val_type == ast.string_type {
573573 g.cur_indexexpr << node.pos.pos
@@ -609,8 +609,8 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) {
609609 g.write ('${zero} })))' )
610610 }
611611 } else if ! gen_or && (g.inside_map_postfix || g.inside_map_infix
612- || g.inside_map_index || g.inside_array_index || (g.is_assign_lhs && ! g.is_arraymap_set
613- && get_and_set_types)) {
612+ || g.inside_map_index || g.inside_array_index || g.inside_left_shift
613+ || (g.is_assign_lhs && ! g.is_arraymap_set && get_and_set_types)) {
614614 zero := g.type_default (val_type)
615615 if use_get_and_set {
616616 g.write ('(*(${val_type_str} *)builtin__map_get_and_set((map*)' )
You can’t perform that action at this time.
0 commit comments