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

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

This commit is contained in:
Delyan Angelov 2020-05-24 20:55:04 +03:00
parent 641fe5c864
commit 23e8c8ecda

View File

@ -1855,6 +1855,13 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
ast.Var { ast.Var {
mut typ := it.typ mut typ := it.typ
if typ == 0 { 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) typ = c.expr(it.expr)
} }
is_optional := typ.flag_is(.optional) is_optional := typ.flag_is(.optional)