checker: error if variable used before decleration p1
parent
624005bbd0
commit
8a5ca4cbdc
|
@ -2084,6 +2084,9 @@ pub fn (mut c Checker) ident(mut ident ast.Ident) table.Type {
|
||||||
return obj.typ
|
return obj.typ
|
||||||
}
|
}
|
||||||
ast.Var {
|
ast.Var {
|
||||||
|
if ident.pos.pos < obj.pos.pos {
|
||||||
|
c.error('variable `$ident.name` used before decleration', ident.pos)
|
||||||
|
}
|
||||||
mut typ := obj.typ
|
mut typ := obj.typ
|
||||||
if typ == 0 {
|
if typ == 0 {
|
||||||
if obj.expr is ast.Ident {
|
if obj.expr is ast.Ident {
|
||||||
|
|
Loading…
Reference in New Issue