Skip to content

ReferenceError on a valid code. #18

@w32zhong

Description

@w32zhong
var result = [];
for (var i=0; i<2; i++) {
    (function () {
        var copy = i;
        var func = function () {
            return copy;
        };
        result.push(func);
    }());
}

console.log(result[0]());

Flat will report Reference error while node engine does not:

$ ./flathead/bin/flat ./test.js 
ReferenceError: copy is not defined
  at ./test.js:6:10
  at (anonymous function) in ./test.js:12:22
$ node ./test.js 
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions