checker: c2v rune comparison fix

master
Alexander Medvednikov 2022-05-04 06:49:45 +03:00
parent 3732db2bcc
commit 1e9156fd71
2 changed files with 4 additions and 1 deletions

View File

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

View File

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