File tree Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Expand file tree Collapse file tree 1 file changed +5
-15
lines changed Original file line number Diff line number Diff line change @@ -150,21 +150,11 @@ fn (mut c Checker) for_stmt(mut node ast.ForStmt) {
150150 c.error ('non-bool used as for condition' , node.pos)
151151 }
152152 if mut node.cond is ast.InfixExpr {
153- infix := node.cond
154- if infix.op == .key_is {
155- if infix.right is ast.TypeNode && infix.left in [ast.Ident, ast.SelectorExpr] {
156- is_variable := if mut infix.left is ast.Ident {
157- infix.left.kind == .variable
158- } else {
159- true
160- }
161- left_type := c.expr (infix.left)
162- left_sym := c.table.sym (left_type)
163- if is_variable {
164- if left_sym.kind in [.sum_type, .interface_] {
165- c.smartcast (infix.left, infix.left_type, infix.right.typ, mut
166- node.scope)
167- }
153+ if node.cond.op == .key_is {
154+ if node.cond.right is ast.TypeNode && node.cond.left in [ast.Ident, ast.SelectorExpr] {
155+ if c.table.type_kind (node.cond.left_type) in [.sum_type, .interface_] {
156+ c.smartcast (node.cond.left, node.cond.left_type, node.cond.right_type, mut
157+ node.scope)
168158 }
169159 }
170160 }
You can’t perform that action at this time.
0 commit comments