estools / escope

Escope: ECMAScript scope analyzer
BSD 2-Clause "Simplified" License
546 stars 77 forks source link

Function declarations attached to block scope? #126

Open ivanbacher opened 6 years ago

ivanbacher commented 6 years ago

Say we have the following code:

{
    function aa() {

    }

    var zz;
}

function bb() {

}

which produces the following scope tree:

0: GlobalScope
1: BlockScope
2: FunctionScope
3: FunctionScope

However, if we take a look at the variables array from the global scope object:

screen shot 2017-11-20 at 16 20 38

we can see that only two variables belong to the global scope, zz and bb. Should aa not also belong to the global scope as it gets hoisted?

0xdevalias commented 11 months ago

Potentially related: