compiler: implement shadowing of global variables

Before introducing slots it was hard to change global variables
preserving changes across multiple function calls.
This commit implements such possibility.
Closes #638.
This commit is contained in:
Evgenii Stratonikov 2020-05-08 16:10:33 +03:00
parent 0cb6dc47e4
commit e21015233b
2 changed files with 24 additions and 0 deletions

View file

@ -410,6 +410,9 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
if !multiRet {
c.registerDebugVariable(t.Name, n.Rhs[i])
}
if t.Name != "_" {
c.scope.newLocal(t.Name)
}
fallthrough
default:
if i == 0 || !multiRet {