Skip to content

Commit 4ac610c

Browse files
authored
cgen: avoid builtin print handling for user print fns (#26781)
1 parent 19532b7 commit 4ac610c

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

vlib/v/gen/c/fn.v

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ fn (mut g Gen) fn_call(node ast.CallExpr) {
20822082
}
20832083
}
20842084
}
2085-
is_print := node.kind in [.print, .println, .eprint, .eprintln, .panic]
2085+
mut is_print := !is_selector_call && node.kind in [.print, .println, .eprint, .eprintln, .panic]
20862086
print_method := name
20872087
is_json_encode := node.kind == .json_encode
20882088
is_json_encode_pretty := node.kind == .json_encode_pretty
@@ -2186,6 +2186,9 @@ fn (mut g Gen) fn_call(node ast.CallExpr) {
21862186
if func.mod == 'builtin' && !name.starts_with('builtin__') && node.language != .c {
21872187
name = 'builtin__${name}'
21882188
}
2189+
is_print = is_print && func.mod == 'builtin'
2190+
} else {
2191+
is_print = false
21892192
}
21902193
}
21912194
if node.is_fn_a_const {
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
void main__print(voidptr fmt, ... );
2+
main__print("\n");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// vtest vflags: -no-builtin
2+
@[markused]
3+
pub fn error() {
4+
print(c'\n')
5+
}
6+
7+
pub fn print(fmt voidptr, ...) {}

0 commit comments

Comments
 (0)