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

buildCodeFrameError errors when using babel-traverse standalone (T7513) #4413

Closed
babel-bot opened this issue Jul 27, 2016 · 1 comment · Fixed by #5050
Closed

buildCodeFrameError errors when using babel-traverse standalone (T7513) #4413

babel-bot opened this issue Jul 27, 2016 · 1 comment · Fixed by #5050
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@babel-bot
Copy link
Collaborator

Issue originally made by @spicyj

Bug information

  • Babel version: 6.11.6
  • Node version: 6
  • npm version: 3

Description

var traverse = require('babel-traverse').default, babylon = require('babylon');
traverse(babylon.parse('let x; let x;'))

should throw an error about duplicate bindings, but it throws

TypeError: Cannot read property file of undefined
    at Scope.checkBlockScopedCollisions (node_modules/babel-traverse/lib/scope/index.js:492:21)
    at Scope.registerBinding (node_modules/babel-traverse/lib/scope/index.js:681:16)
    at Scope.registerDeclaration (node_modules/babel-traverse/lib/scope/index.js:580:14)
    ...
    at TraversalContext.visit (node_modules/babel-traverse/lib/context.js:219:19)
    at Function.traverse.node (node_modules/babel-traverse/lib/index.js:171:17)
    at traverse (node_modules/babel-traverse/lib/index.js:90:12)
    at repl:1:81

instead because this.hub is undefined on this line:

throw this.hub.file.buildCodeFrameError(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
.

Can we fix this as-is? Do I need to pass in a File object of some sort (how would I construct one)?

(I'm actually passing sourceFilename and code to traverse already.)

@sompylasar
Copy link

Refs #4640

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 5, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants