fix bool expressions
							parent
							
								
									806691c1db
								
							
						
					
					
						commit
						edf8a2cd08
					
				| 
						 | 
					@ -30,8 +30,8 @@ void function2() {
 | 
				
			||||||
	while (true) {
 | 
						while (true) {
 | 
				
			||||||
		foo(0);
 | 
							foo(0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	int e = 1 + 2 > 0;
 | 
						bool e = 1 + 2 > 0;
 | 
				
			||||||
	int e2 = 1 + 2 < 0;
 | 
						bool e2 = 1 + 2 < 0;
 | 
				
			||||||
	int j = 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() {
 | 
							else if prev_tok.is_left_assoc() {
 | 
				
			||||||
			mut expr := ast.Expr{}
 | 
								mut expr := ast.Expr{}
 | 
				
			||||||
			expr,t2 = p.expr(prev_tok.precedence())
 | 
								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')
 | 
								// println(t2.name + '222')
 | 
				
			||||||
			node = ast.BinaryExpr{
 | 
								node = ast.BinaryExpr{
 | 
				
			||||||
				left: node
 | 
									left: node
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue