benjamn / benjamn/ast-types

Does anyone know how to distinguish whether it is the same variable in ast?

Open
#479 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
194
Avg merge
22h 43m
Merged PRs (30d)
10

Description

![img](https://files.gitter.im/529f74f4ed5ab0b3bf04ef26/ltiP/image.png)

```javasript
const { parse, print, visit } = require('recast')

const ast = parse(`function test(samename){
samename(123);
var b = {
c: function (samename){
samename(456)
},
d: function() {
samename(789)
}
}
}`)

const funcAst = ast.program.body[0]

const arg = funcAst.params[0]

console.log(arg)

visit(funcAst, {
visitCallExpression(path) {
console.log(path.value.callee)
this.traverse(path)
}
})
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the parse(...) result and the visit(funcAst, ...) traversal shown in the issue, then inspect how the displayed call-expression callees relate to their surrounding functions. Determine how to distinguish the outer and inner samename bindings, and document or demonstrate a reliable way to identify them.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.