Restrict var statements to the top of functions

This commit is contained in:
Nigel Tao committed 2018-12-27 11:19:22 +11:00
1 parent 84f9d3a915
commit cbe19f50e0
5 files changed
+36 -56

No files matched your search

+1 -3
View File
@@ -540,9 +540,7 @@ func (c *Checker) checkFuncBody(node *a.Node) error {
localVars: c.localVars[n.QQID()],
}
// Fill in the TypeMap with all local variables. Note that they have
// function scope and can be hoisted, JavaScript style, a la
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/var
// Fill in the TypeMap with all local variables.
if err := q.tcheckVars(n.Body()); err != nil {
return &Error{
Err: err,