checker: check if $if left is selector expr (#7897)

pull/7900/head
Daniel Däschle 2021-01-05 17:14:55 +01:00 committed by GitHub
parent 7135773975
commit c137a79666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -4237,11 +4237,13 @@ pub fn (mut c Checker) if_expr(mut node ast.IfExpr) table.Type {
// smartcast field type on comptime if
if branch.cond is ast.InfixExpr {
if branch.cond.op == .key_is {
se := branch.cond.left as ast.SelectorExpr
se := branch.cond.left
if se is ast.SelectorExpr {
got_type := (branch.cond.right as ast.Type).typ
c.comptime_fields_type[se.expr.str()] = got_type
}
}
}
cur_skip_flags := c.skip_flags
if found_branch {
c.skip_flags = true