diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index 5c5698032f..f579395082 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -759,7 +759,8 @@ fn (mut g Gen) gen_str_for_map(info ast.Map, styp string, str_fn_name string) { tmp_str := str_intp_rune('${elem_str_fn_name}(*(${val_styp}*)DenseArray_value(&m.key_values, i))') g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, ${tmp_str});') } else { - g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, ${elem_str_fn_name}(*(${val_styp}*)DenseArray_value(&m.key_values, i)));') + ptr_str := '*'.repeat(val_typ.nr_muls()) + g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, ${elem_str_fn_name}(*${ptr_str}(${val_styp}*)DenseArray_value(&m.key_values, i)));') } g.auto_str_funcs.writeln('\t\tif (i != m.key_values.len-1) {') g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT(", "));') diff --git a/vlib/v/tests/map_reference_value_test.v b/vlib/v/tests/map_reference_value_test.v index 6d5680a1ed..ee60e0d8da 100644 --- a/vlib/v/tests/map_reference_value_test.v +++ b/vlib/v/tests/map_reference_value_test.v @@ -1,3 +1,5 @@ +import datatypes + struct Foo { bar string } @@ -15,3 +17,9 @@ fn test_map_reference_value() { assert true } + +fn test_map_reference_value2() { + mut m := map[string]&datatypes.Queue[i64]{} + println('${m}') + assert '${m}' == '{}' +}