checker: correct pos for type error of `if v is interface` (#9080)
parent
8a0b5bad94
commit
c74fa9e471
|
@ -4824,7 +4824,7 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) table.Type {
|
||||||
left_sym := c.table.get_type_symbol(infix.left_type)
|
left_sym := c.table.get_type_symbol(infix.left_type)
|
||||||
expr_type := c.expr(infix.left)
|
expr_type := c.expr(infix.left)
|
||||||
if left_sym.kind == .interface_ {
|
if left_sym.kind == .interface_ {
|
||||||
c.type_implements(right_expr.typ, expr_type, branch.pos)
|
c.type_implements(right_expr.typ, expr_type, branch.cond.position())
|
||||||
} else if !c.check_types(right_expr.typ, expr_type) {
|
} else if !c.check_types(right_expr.typ, expr_type) {
|
||||||
expect_str := c.table.type_to_str(right_expr.typ)
|
expect_str := c.table.type_to_str(right_expr.typ)
|
||||||
expr_str := c.table.type_to_str(expr_type)
|
expr_str := c.table.type_to_str(expr_type)
|
||||||
|
|
|
@ -5,10 +5,10 @@ vlib/v/checker/tests/is_type_invalid.vv:14:12: error: `IoS` has no variant `byte
|
||||||
| ~~
|
| ~~
|
||||||
15 | println('not cool')
|
15 | println('not cool')
|
||||||
16 | }
|
16 | }
|
||||||
vlib/v/checker/tests/is_type_invalid.vv:18:2: error: `Cat` doesn't implement method `speak` of interface `Animal`
|
vlib/v/checker/tests/is_type_invalid.vv:18:5: error: `Cat` doesn't implement method `speak` of interface `Animal`
|
||||||
16 | }
|
16 | }
|
||||||
17 | a := Animal(Dog{})
|
17 | a := Animal(Dog{})
|
||||||
18 | if a is Cat {
|
18 | if a is Cat {
|
||||||
| ~~~~~~~~~~~
|
| ~~~~~~~~
|
||||||
19 | println('not cool either')
|
19 | println('not cool either')
|
||||||
20 | }
|
20 | }
|
||||||
|
|
Loading…
Reference in New Issue