1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: don't show manual memory warning twice (#15510)

This commit is contained in:
StunxFS 2022-08-24 02:08:35 -04:00 committed by GitHub
parent 6ff753745f
commit 0d8b6ee7f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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