Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable erroneously tagged as ImplicitGlobalVariable #22

Closed
pigulla opened this issue Aug 16, 2013 · 3 comments
Closed

Variable erroneously tagged as ImplicitGlobalVariable #22

pigulla opened this issue Aug 16, 2013 · 3 comments

Comments

@pigulla
Copy link

pigulla commented Aug 16, 2013

This is probably a regression bug for the fix introduced in #21

Test script:

var escope = require("escope"),
    esprima = require("esprima");

var src = require("fs").readFileSync("source.js");

var ast = esprima.parse(src),
    scopes = escope.analyze(ast).scopes;

console.dir(scopes[0].variables[0].defs.map(function (def) {
    return def.type
}));

Input source:

var a; a = 42;

Output with escope 0.14.0:
[ 'Variable' ]

Output with escope 0.15.0 and 0.16.0:
[ 'Variable', 'ImplicitGlobalVariable' ]

@Constellation
Copy link
Member

Nice catch! I'll fix it.

@Constellation
Copy link
Member

ImplicitGlobalVariable is something different with normal Variables.

For example,

function inner() {
    eval(str);
    x = 20;
}

When this script is analyzed, x should be ImplicitGlobalVariable or not?

Treating ImplicitVariable as normal variables may break consistency.
I think adding new field globalScope.implicitVariables, adding implicit variables to it and removing implicit variables from normal variable map is better.

@Constellation
Copy link
Member

I've added globalScope.implicit field and remove ImplicitGlobals from scope.variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants