tern icon indicating copy to clipboard operation
tern copied to clipboard

Scopes are wrong

Open boopeshmahendran opened this issue 7 years ago • 0 comments
trafficstars

I passed this code in tern and used infer.scopeAt to find scope var y = 2 line

function a() {
    var x = 1;
    function b() {
        var y = 2;
    }
}

I thought that the prev scope to b's scope should be a's scope.

But the previous scope to the function b's scope is a block scope which has props only b(i.e the b function) whereas it should be the function a's scope which should have props both x and b. See the below image.

capture

I went through the infer.js code and found that this line is causing this. I think that function declaration should not be considered as a block scoped declaration.

boopeshmahendran avatar Dec 07 '17 16:12 boopeshmahendran