From cab53d0e75a83d950135daa68fda1925d68e4325 Mon Sep 17 00:00:00 2001 From: playX Date: Mon, 25 Apr 2022 22:34:26 +0000 Subject: [PATCH] checker: c2v fixes (#14161) --- vlib/builtin/cfns.c.v | 3 +++ vlib/v/checker/check_types.v | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index c20bf0198f..31e49c7cac 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -482,3 +482,6 @@ fn C.glTexImage2D() // used by ios for println fn C.WrappedNSLog(str &u8) + +// absolute value +fn C.abs(number int) int diff --git a/vlib/v/checker/check_types.v b/vlib/v/checker/check_types.v index 1d8f8929dd..4f5fd0feac 100644 --- a/vlib/v/checker/check_types.v +++ b/vlib/v/checker/check_types.v @@ -19,6 +19,10 @@ pub fn (mut c Checker) check_types(got ast.Type, expected ast.Type) bool { if expected == ast.voidptr_type { return true } + if expected == ast.bool_type && (got.is_any_kind_of_pointer() || got.is_int()) { + return true + } + if expected.is_any_kind_of_pointer() { //&& !got.is_any_kind_of_pointer() { // Allow `int` as `&i8` etc in C code. deref := expected.deref()