1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
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

View File

@ -4237,9 +4237,11 @@ 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
got_type := (branch.cond.right as ast.Type).typ
c.comptime_fields_type[se.expr.str()] = got_type
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