mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fix bool expressions
This commit is contained in:
parent
806691c1db
commit
edf8a2cd08
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user