1 | if node.op == .amp && left_type.is_bool() && right_type.is_bool() && right_type.is_ptr() { |
2 | pos := node.pos.extend(node.right.pos()) |
3 | c.error('the right expression should be separated from the `&&` by a space', pos) |
4 | + node.promoted_type = ast.bool_type |
5 | return ast.bool_type |
6 | } |
7 | node.right_type = right_type |
8 | node.pos) |
9 | } |
10 | } |
11 | + node.promoted_type = ast.bool_type |
12 | return ast.bool_type |
13 | } |
14 | .plus, .minus, .mul, .div, .mod, .xor, .amp, .pipe { |
15 | c.error('only `==` and `!=` are defined on arrays', node.pos) |
16 | } else if left_sym.kind == .struct_ |
17 | && (left_sym.info as ast.Struct).generic_types.len > 0 { |
18 | + node.promoted_type = ast.bool_type |
19 | return ast.bool_type |
20 | } else if left_sym.kind == .struct_ && right_sym.kind == .struct_ |
21 | && node.op in [.eq, .lt] { |
22 | c.error('cannot append `${right_sym.name}` to `${left_sym.name}`', right_pos) |
23 | return ast.void_type |
24 | } else { |
25 | - return c.check_shift(mut node, left_type, right_type) |
26 | + node.promoted_type = c.check_shift(mut node, left_type, right_type) |
27 | + return node.promoted_type |
28 | } |
29 | } |
30 | .right_shift { |
31 | - return c.check_shift(mut node, left_type, right_type) |
32 | + node.promoted_type = c.check_shift(mut node, left_type, right_type) |
33 | + return node.promoted_type |
34 | } |
35 | .unsigned_right_shift { |
36 | modified_left_type := if !left_type.is_int() { |
37 | or_block: node.or_block |
38 | } |
39 | |
40 | - return c.check_shift(mut node, left_type, right_type) |
41 | + node.promoted_type = c.check_shift(mut node, left_type, right_type) |
42 | + |
43 | + return node.promoted_type |
44 | } |
45 | .key_is, .not_is { |
46 | right_expr := node.right |
47 | } |
48 | } |
49 | } |
50 | + node.promoted_type = ast.bool_type |
51 | return ast.bool_type |
52 | } |
53 | .arrow { // `chan <- elem` |
54 | } |
55 | if left_type.nr_muls() > 0 && right_type.is_int() { |
56 | // pointer arithmetic is fine, it is checked in other places |
57 | + node.promoted_type = return_type |
58 | return return_type |
59 | } |
60 | c.error('infix expr: cannot use `${right_sym.name}` (right expression) as `${left_sym.name}`', |
61 | c.warn('`++` and `--` are statements, not expressions', node.pos) |
62 | } |
63 | */ |
64 | - return if node.op.is_relational() { ast.bool_type } else { return_type } |
65 | + node.promoted_type = if node.op.is_relational() { ast.bool_type } else { return_type } |
66 | + return node.promoted_type |
67 | } |
68 | |
69 | fn (mut c Checker) check_div_mod_by_zero(expr ast.Expr, op_kind token.Kind) { |
70 | |