From 1e9156fd7177ede1576b7712c65094e2edd4651b Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 4 May 2022 06:49:45 +0300 Subject: [PATCH] checker: c2v rune comparison fix --- vlib/builtin/cfns.c.v | 2 ++ vlib/v/checker/checker.v | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/vlib/builtin/cfns.c.v b/vlib/builtin/cfns.c.v index 9b7eb0d2d4..6c76248e10 100644 --- a/vlib/builtin/cfns.c.v +++ b/vlib/builtin/cfns.c.v @@ -93,6 +93,8 @@ fn C._execve(cmd_path &char, args voidptr, envs voidptr) int fn C._execvp(cmd_path &char, args &&char) int +fn C.strcmp(s1 &char, s2 &char) int + [trusted] fn C.fork() int diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 682394163c..a56b23681b 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -648,7 +648,8 @@ pub fn (mut c Checker) infix_expr(mut node ast.InfixExpr) ast.Type { rs, _ := c.table.type_size(right_type) // prevent e.g. `u32 == i16` but not `u16 == i32` as max_u16 fits in i32 // TODO u32 == i32, change < to <= - if (is_left_type_signed && ls < rs) || (is_right_type_signed && rs < ls) { + if !c.pref.translated && ((is_left_type_signed && ls < rs) + || (is_right_type_signed && rs < ls)) { lt := c.table.sym(left_type).name rt := c.table.sym(right_type).name c.error('`$lt` cannot be compared with `$rt`', node.pos)