From 0d8b6ee7f2f935d78ebedfa4445a0ebb6bf72dfd Mon Sep 17 00:00:00 2001 From: StunxFS <56417208+StunxFS@users.noreply.github.com> Date: Wed, 24 Aug 2022 02:08:35 -0400 Subject: [PATCH] checker: don't show manual memory warning twice (#15510) --- vlib/v/checker/fn.v | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 432cf40c56..eb60cad43e 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -1165,10 +1165,6 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { return ast.int_type } } - if !c.is_builtin_mod && !c.inside_unsafe && method_name == 'free' { - c.warn('manual memory management with `free()` is only allowed in unsafe code', - node.pos) - } if left_type == ast.void_type { // No need to print this error, since this means that the variable is unknown, // and there already was an error before. @@ -1602,6 +1598,10 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { c.fail_if_unreadable(node.left, left_type, 'receiver') return ast.string_type } else if method_name == 'free' { + if !c.is_builtin_mod && !c.inside_unsafe && !method.is_unsafe { + c.warn('manual memory management with `free()` is only allowed in unsafe code', + node.pos) + } return ast.void_type } // call struct field fn type