benjamn / benjamn/recast

getBindings doesn't detect a closure's free variables

Open
#397 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.3k
Forks
363
Avg merge
3d 8h
Merged PRs (30d)
3

Description

```javascript
> 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 }
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the getBindings implementation and reproduce the issue using the JavaScript snippet in the report. Trace the scope handling for the function assigned to x, then verify that the closure's reference to bb is detected as a free variable and that the existing binding checks reflect it.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.