checker: prevent infinite recursion on a:=b b:=a

pull/5009/head
Delyan Angelov 2020-05-24 20:55:04 +03:00
parent 641fe5c864
commit 23e8c8ecda
1 changed files with 7 additions and 0 deletions

View File

@ -1855,6 +1855,13 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
ast.Var {
mut typ := it.typ
if typ == 0 {
if it.expr is ast.Ident {
inner_ident := it.expr as ast.Ident
if inner_ident.kind == .unresolved {
c.error('unresolved variable: `$ident.name`', ident.pos)
return table.void_type
}
}
typ = c.expr(it.expr)
}
is_optional := typ.flag_is(.optional)