checker: vfmt fn.v

This commit is contained in:
Alexander Medvednikov 2025-01-14 01:24:45 +03:00
parent a20fff99e0
commit 78f34e6c89
2 changed files with 4 additions and 3 deletions

View File

@ -10,7 +10,7 @@ const text_size = 16
struct App {
mut:
gg &gg.Context = unsafe { nil }
dropped_file_list []string = []string{}
dropped_file_list []string
}
fn main() {

View File

@ -1766,10 +1766,11 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
// bug with fn...
// fn f(p &Foo) => f(foo) -- do not allow this, force f(&foo)
// if !c.is_builtin_mod
if param.typ == ast.voidptr_type && func.language == .v
else if param.typ == ast.voidptr_type && func.language == .v
&& arg_typ !in [ast.voidptr_type, ast.nil_type] && arg_typ.nr_muls() == 0
&& func.name !in ['isnil', 'ptr_str'] && !func.name.starts_with('json.')
&& arg_typ_sym.kind !in [.float_literal, .int_literal] && !c.pref.backend.is_js() {
&& arg_typ_sym.kind !in [.float_literal, .int_literal, .charptr]
&& !c.pref.backend.is_js() {
c.warn('automatic ${arg_typ_sym.name} referencing/dereferencing into voidptr is deprecated and will be removed soon; use `foo(&x)` instead of `foo(x)`',
call_arg.pos)
}