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

Parent scope BlockStatement incorrectly resolved from inside SwitchStatement (T6761) #3823

Closed
babel-bot opened this issue Dec 4, 2015 · 4 comments
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 @loganfsmyth

Input code



function fn(...args){
    console.log(args);
}

var args = [1, 2, 3];
var obj = {
    obj: {fn}
};

switch (true){
    case true:
        obj.obj.fn(...args);
        break;
}

Description

Regression from https://phabricator.babeljs.io/T3051

Output:

TypeError: main.js: Cannot read property '0' of undefined
    at Function.get (<babel>/packages/babel-traverse/lib/path/index.js:89:31)
    at NodePath.unshiftContainer (<babel>/packages/babel-traverse/lib/path/modification.js:244:33)
    at Scope.push (<babel>/packages/babel-traverse/lib/scope/index.js:1029:41)
    at Scope.maybeGenerateMemoised (<babel>/packages/babel-traverse/lib/scope/index.js:469:27)
    at PluginPass.CallExpression (<babel>/packages/babel-plugin-transform-es2015-spread/lib/index.js:116:28)
    at newFn (<babel>/packages/babel-traverse/lib/visitors.js:276:19)
    at NodePath._call <babel>/packages/babel-traverse/lib/path/context.js:74:18)
    at NodePath.call (<babel>/packages/babel-traverse/lib/path/context.js:46:17)
    at NodePath.visit (<babel>/packages/babel-traverse/lib/path/context.js:104:12)
    at TraversalContext.visitQueue (<babel>/packages/babel-traverse/lib/context.js:153:16)
@babel-bot
Copy link
Collaborator Author

Comment originally made by @loganfsmyth

PR: #3133

@babel-bot
Copy link
Collaborator Author

Comment originally made by @loganfsmyth

@prewk This has been fixed in babel-traverse@6.3.14, so if you make sure your deps are fully updated, you should be set.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @prewk

Fantastic, thank you.

@babel-bot
Copy link
Collaborator Author

Comment originally made by @prewk

It's not on npm yet, right? https://www.npmjs.com/package/babel Only 6.3.13 here.

edit: Nvm, I know it's babel-traverse, just had to figure out to remove babel-core completely and reinstall it.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 9, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 9, 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

No branches or pull requests

1 participant