-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Bug Report
Current Behavior
an exception occurs when instrumenting valid JavaScript syntax.
Input Code
function apple() {}
apple.prototype.foo = function foo () {
let foo = 99
console.info(foo)
}
apple.prototype.foo()☝️ the above code results in the following exception:
TypeError: Cannot read property 'file' of undefined
at Scope.checkBlockScopedCollisions (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/scope/index.js:398:22)
at Scope.registerBinding (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/scope/index.js:592:16)
at Scope.registerDeclaration (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/scope/index.js:496:14)
at Object.BlockScoped (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/scope/index.js:244:28)
at Object.newFn (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/visitors.js:318:17)
at NodePath._call (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/path/context.js:44:14)
at NodePath.visit (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/path/context.js:105:12)
at TraversalContext.visitQueue (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitMultiple (/Users/benjamincoe/oss/node/node_modules/nyc/node_modules/babel-traverse/lib/context.js:103:17)Expected behavior/code
no exception occurs during instrumentation.
Environment
- Babel version(s): [e.g. v6]
- Node/npm version: [e.g. Node 8/npm 5]
- OS: [e.g. OSX 10.13.4, Windows 10]
- Monorepo [e.g. yes/no/Lerna]
- How you are using Babel: [e.g.
programmatically]
Possible Solution
var duplicate = kind === "let" || local.kind === "let" || local.kind === "const" || local.kind === "module" || local.kind === "param" && (kind === "let" || kind === "const");
if (duplicate) {
throw this.hub.file.buildCodeFrameError(id, messages.get("scopeDuplicateDeclaration", name), TypeError);
}☝️ this logic seems a little bit wonky in general, why is "let" being checked for in the left-hand-side of the OR and not "const" for starters.
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue