Skip to content

Commit

Permalink
improve expr.str()
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Oct 29, 2024
1 parent 7da8363 commit 52deb5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion vlib/v/ast/str.v
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,11 @@ pub fn (x &Expr) str() string {
if x.name.contains('__static__') {
return '${x.mod}.${x.get_name()}(${sargs})${propagate_suffix}'
}
return '${x.mod}.${x.get_name()}(${sargs})${propagate_suffix}'
if x.mod == 'main' {
return '${x.get_name()}(${sargs})${propagate_suffix}'
} else {
return '${x.mod}.${x.get_name()}(${sargs})${propagate_suffix}'
}
}
CharLiteral {
return '`${x.val}`'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:14] voidptr(abc) == voidptr(cpu_get_id): true
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:15] main.cpu_get_id(): 123
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:15] cpu_get_id(): 123
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:16] abc(): 123
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:17] abc() == main.cpu_get_id(): true
[vlib/v/checker/tests/globals_run/function_stored_in_global.vv:17] abc() == cpu_get_id(): true

0 comments on commit 52deb5e

Please sign in to comment.