diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index f1be4029d1..a1834960ff 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -4757,7 +4757,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) table.Type { cond_typ := c.expr(branch.cond) if cond_typ.idx() != table.bool_type_idx && !c.pref.translated { typ_sym := c.table.get_type_symbol(cond_typ) - c.error('non-bool type `$typ_sym.name` used as if condition', branch.pos) + c.error('non-bool type `$typ_sym.name` used as if condition', branch.cond.position()) } } } diff --git a/vlib/v/checker/tests/if_non_bool_cond.out b/vlib/v/checker/tests/if_non_bool_cond.out index ecb8ff6dcd..08c9765312 100644 --- a/vlib/v/checker/tests/if_non_bool_cond.out +++ b/vlib/v/checker/tests/if_non_bool_cond.out @@ -1,20 +1,20 @@ -vlib/v/checker/tests/if_non_bool_cond.vv:2:2: error: non-bool type `string` used as if condition +vlib/v/checker/tests/if_non_bool_cond.vv:2:5: error: non-bool type `string` used as if condition 1 | fn main() { 2 | if '10' { - | ~~~~~~~ + | ~~~~ 3 | println('10') 4 | } -vlib/v/checker/tests/if_non_bool_cond.vv:6:2: error: non-bool type `int literal` used as if condition +vlib/v/checker/tests/if_non_bool_cond.vv:6:5: error: non-bool type `int literal` used as if condition 4 | } 5 | 6 | if 5 { - | ~~~~ + | ^ 7 | println(5) 8 | } -vlib/v/checker/tests/if_non_bool_cond.vv:10:2: error: non-bool type `void` used as if condition +vlib/v/checker/tests/if_non_bool_cond.vv:10:5: error: non-bool type `void` used as if condition 8 | } 9 | 10 | if println('v') { - | ~~~~~~~~~~~~~~~ + | ~~~~~~~~~~~~ 11 | println('println') 12 | }