v.debug: fix $dbg with @[heap] structs (fix #23979) (#23989)

This commit is contained in:
Felipe Pena 2025-03-21 03:33:02 -03:00 committed by GitHub
parent a9a96b897e
commit 76ae040f71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View File

@ -0,0 +1,10 @@
#!/usr/bin/env expect
source "common.tcl"
expect "Break on * main in ${test_file}:8"
expect "${test_file}:8 vdbg> "
send "p st\n"
expect "st = AStruct{\r\n a: 1\r\n} (main.AStruct)"
expect "${test_file}:8 vdbg> "
send "q\n"
expect eof

View File

@ -0,0 +1,10 @@
@[heap]
struct AStruct {
a int
}
fn main() {
st := AStruct{1}
$dbg;
dump(st)
}

View File

@ -4527,6 +4527,8 @@ fn (mut g Gen) debugger_stmt(node ast.DebuggerStmt) {
'&' '&'
} else if !str_method_expects_ptr && obj.typ.is_ptr() { } else if !str_method_expects_ptr && obj.typ.is_ptr() {
'*'.repeat(obj.typ.nr_muls()) '*'.repeat(obj.typ.nr_muls())
} else if !str_method_expects_ptr && obj_sym.is_heap() {
'*'
} else if obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr { } else if obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr {
'*' '*'
} else if !obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr { } else if !obj.is_auto_heap && var_typ.is_ptr() && str_method_expects_ptr {