Skip to content

Commit fb52cd9

Browse files
authored
cgen: fix generic multiple indirections on print (fix #22793) (#25633)
1 parent ecd7094 commit fb52cd9

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

vlib/v/gen/c/str.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) {
232232
if str_method_expects_ptr && !is_ptr && !typ.has_flag(.option) {
233233
g.write('&')
234234
} else if (!str_method_expects_ptr && is_ptr && !is_shared) || is_var_mut {
235-
g.write('*')
235+
g.write('*'.repeat(typ.nr_muls()))
236236
} else {
237237
if sym.is_c_struct() {
238238
g.write(c_struct_ptr(sym, typ, str_method_expects_ptr))
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fn test_main() {
2+
la := 'lalala'
3+
la2 := &la
4+
la3 := &la2
5+
a(la3)
6+
}
7+
8+
fn a[T](t &&T) {
9+
println(t)
10+
dump(t)
11+
assert **t == 'lalala'
12+
}

0 commit comments

Comments
 (0)