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

Destructuring assignment fails in 0.2 and 0.3 with babel7 #802

Closed
diervo opened this issue Feb 22, 2018 · 5 comments
Closed

Destructuring assignment fails in 0.2 and 0.3 with babel7 #802

diervo opened this issue Feb 22, 2018 · 5 comments
Labels
bug Confirmed bug

Comments

@diervo
Copy link

diervo commented Feb 22, 2018

Input Code

function x() {
    const { method } = $api;
}

Actual Output

TypeError: undefined: Duplicate declaration "b" (This is an error on an internal node. Probably an internal error.)
    at File.buildCodeFrameError (/x/node_modules/@babel/core/lib/transformation/file/file.js:207:12)
    at Scope.checkBlockScopedCollisions (/x/node_modules/@babel/traverse/lib/scope/index.js:303:27)
    at Scope.registerBinding (/x/node_modules/@babel/traverse/lib/scope/index.js:485:16)
    at Scope.registerDeclaration (/x/node_modules/@babel/traverse/lib/scope/index.js:404:14)
    at Object.BlockScoped (/x/node_modules/@babel/traverse/lib/scope/index.js:146:28)
    at Object.newFn (/x/node_modules/@babel/traverse/lib/visitors.js:266:17)
    at NodePath._call (/x/node_modules/@babel/traverse/lib/path/context.js:64:19)
    at NodePath.call (/x/node_modules/@babel/traverse/lib/path/context.js:34:14)
    at NodePath.visit (/x/node_modules/@babel/traverse/lib/path/context.js:99:12)
    at TraversalContext.visitQueue (/x/node_modules/@babel/traverse/lib/context.js:135:18)

Expected Output

function x() {
  var _$api = $api,
    a = _$api.method;
}

Details

I narrow down the bug to the babel-plugin-minify-mangle-names plugin.

This reproduces in preset package 0.2 and 0.3 when using babel 7.0.0-beta.40 (I know is not officially support it yet, but since a trivial example fails, I wonder if there will more of these bugs).

I will try to figure out the root cause and submit a PR, but in the mean time any hints from the owners of the code will be appreciated.

@diervo diervo changed the title Destructuring assignment fails in 0.2 and 0.3 Destructuring assignment fails in 0.2 and 0.3 with babel7 Feb 22, 2018
@boopathi boopathi added the bug Confirmed bug label Feb 22, 2018
@boopathi
Copy link
Member

boopathi commented Feb 22, 2018

Thanks for trying this out with babel-7.

I'm debugging this right now and fixed the mentioned issue (Duplicate declaration), but after this fix, there is something else that's broken as well. I will fix that and update.

@diervo
Copy link
Author

diervo commented Feb 22, 2018

@boopathi let me know how I can help, is there a branch I can take a look at?
Once you figure out a fix I can push our own packages to get over the hump.

@boopathi
Copy link
Member

boopathi commented Feb 23, 2018

I pushed to the branch: babel-7

PR - #487

@diervo
Copy link
Author

diervo commented Feb 23, 2018

Thanks for the quick turnaround will give it a run and report back

@boopathi
Copy link
Member

babel-7 is merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants