checker: fix `T is int`
parent
d088c4cee3
commit
0bc80951e3
|
@ -5982,7 +5982,8 @@ fn (mut c Checker) comp_if_branch(cond ast.Expr, pos token.Position) bool {
|
||||||
type_node := cond.right as ast.TypeNode
|
type_node := cond.right as ast.TypeNode
|
||||||
sym := c.table.get_type_symbol(type_node.typ)
|
sym := c.table.get_type_symbol(type_node.typ)
|
||||||
if sym.kind != .interface_ {
|
if sym.kind != .interface_ {
|
||||||
c.error('`$sym.name` is not an interface', cond.right.position())
|
c.expr(cond.left)
|
||||||
|
// c.error('`$sym.name` is not an interface', cond.right.position())
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
} else if cond.left is ast.SelectorExpr || cond.left is ast.TypeNode {
|
} else if cond.left is ast.SelectorExpr || cond.left is ast.TypeNode {
|
||||||
|
|
|
@ -319,7 +319,8 @@ fn (mut g Gen) comp_if_cond(cond ast.Expr) bool {
|
||||||
got_type := (cond.right as ast.TypeNode).typ
|
got_type := (cond.right as ast.TypeNode).typ
|
||||||
// Handle `$if x is Interface {`
|
// Handle `$if x is Interface {`
|
||||||
// mut matches_interface := 'false'
|
// mut matches_interface := 'false'
|
||||||
if left is ast.TypeNode && cond.right is ast.TypeNode {
|
if left is ast.TypeNode && cond.right is ast.TypeNode
|
||||||
|
&& g.table.get_type_symbol(got_type).kind == .interface_ {
|
||||||
// `$if Foo is Interface {`
|
// `$if Foo is Interface {`
|
||||||
interface_sym := g.table.get_type_symbol(got_type)
|
interface_sym := g.table.get_type_symbol(got_type)
|
||||||
if interface_sym.info is ast.Interface {
|
if interface_sym.info is ast.Interface {
|
||||||
|
|
Loading…
Reference in New Issue