diff --git a/vlib/v/cgen/tests/2.c b/vlib/v/cgen/tests/2.c index 558bd70a91..d2e8814688 100644 --- a/vlib/v/cgen/tests/2.c +++ b/vlib/v/cgen/tests/2.c @@ -30,8 +30,8 @@ void function2() { while (true) { foo(0); } - int e = 1 + 2 > 0; - int e2 = 1 + 2 < 0; + bool e = 1 + 2 > 0; + bool e2 = 1 + 2 < 0; int j = 0; } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 66fea51427..747198fc24 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -333,6 +333,13 @@ pub fn (p mut Parser) expr(rbp int) (ast.Expr,types.Type) { else if prev_tok.is_left_assoc() { mut expr := ast.Expr{} expr,t2 = p.expr(prev_tok.precedence()) + op := prev_tok.kind + if op in [.gt, .lt, .ge, .le] { + typ = types.bool_type + } + else { + typ = t2 + } // println(t2.name + '222') node = ast.BinaryExpr{ left: node