compiler: support range loops with value variables

Closes #958.
This commit is contained in:
Evgenii Stratonikov 2020-05-19 18:07:29 +03:00
parent b126056f04
commit d0735257ce
3 changed files with 21 additions and 18 deletions

View file

@ -104,6 +104,15 @@ func (c *funcScope) countLocals() int {
// This handles the inline GenDecl like "var x = 2"
case *ast.ValueSpec:
size += len(n.Names)
case *ast.RangeStmt:
if n.Tok == token.DEFINE {
if n.Key != nil {
size++
}
if n.Value != nil {
size++
}
}
}
return true
})