fix bool expressions

pull/3271/head
Alexander Medvednikov 2019-12-30 08:17:58 +01:00
parent 806691c1db
commit edf8a2cd08
2 changed files with 9 additions and 2 deletions

View File

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

View File

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