mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix printing map reference value (#17496)
This commit is contained in:
parent
6f7192359a
commit
30c205ef2c
@ -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(", "));')
|
||||
|
@ -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}' == '{}'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user