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

getBindings doesn't detect a closure's free variables #397

Open
infinity0 opened this issue Apr 12, 2017 · 0 comments
Open

getBindings doesn't detect a closure's free variables #397

infinity0 opened this issue Apr 12, 2017 · 0 comments

Comments

@infinity0
Copy link

> var recast = require("recast");
undefined
> recast.visit(recast.parse("var a, bb; bb = 3; var x = function() { bb = 4; };"), { visitIdentifier: function(path) {
  console.log(path);
  console.log(path.scope.getBindings());
  console.log(path.scope.getBindings().hasOwnProperty(path.node.name));
  console.log("====");
  this.traverse(path);
}});
[..]
[..]
[..]
====
NodePath {
  value: 
   Identifier {
     type: 'Identifier',
     name: 'bb',
     loc: { start: [Object], end: [Object], lines: Lines {}, indent: 0 } },
  parentPath: 
   NodePath {
     value: 
      AssignmentExpression {
        type: 'AssignmentExpression',
        operator: '=',
        [..]
  name: 'left',
  __childCache: null }
{}
false
====
{ program: 
  [..]
  type: 'File',
  comments: null }
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

1 participant