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

Implement ignoreEval option to analyze. Fixes #2. #18

Merged
merged 1 commit into from Jul 2, 2013

Conversation

glasser
Copy link
Contributor

@glasser glasser commented Jul 2, 2013

We want this because we want J in

function () {
  var J;
  J = 3;
  eval("foo");
}

to count as resolved! I'm really not sure why it isn't just because there's an eval there...

@Constellation
Copy link
Member

Hi, thanks for your request.

Direct call to eval can create variable to the local scope, so if there's eval we cannot analyze precise scope

function outer() {
    var i = 42;
    function inner() {
        eval('var i = 0');
        i;  // 0, not 42
    }
}

Direct call to eval can take string, so we cannot analyze it statically.

Escope guarantees precise scope analysis, this is the most important for some tools need precise analysis, such as minifiers. So if it encounters eval, annotating scope direct scope and gives up analysis.

But some tools don't need precise analysis, for such tools we should provide this option.

Constellation added a commit that referenced this pull request Jul 2, 2013
Implement ignoreEval option to analyze. Fixes #2.
@Constellation Constellation merged commit 08a88e6 into estools:master Jul 2, 2013
@Constellation
Copy link
Member

We need consider API interface name, so this ignoreEval option name may be changed when escope is released.

@glasser
Copy link
Contributor Author

glasser commented Jul 2, 2013

Ah, got it. So an eval can make a reference be TIGHTER than you would imagine.

For my particular use case I only really care about implicit global variables, so the only thing I'm concerned about are references that are LOOSER than they look, so ignoreEval is OK. (See #17 for why I don't just look at the global scope...)

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

Successfully merging this pull request may close these issues.

None yet

2 participants