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

Property issue in ObjectPattern #358

Closed
wisec opened this issue Nov 28, 2017 · 3 comments
Closed

Property issue in ObjectPattern #358

wisec opened this issue Nov 28, 2017 · 3 comments

Comments

@wisec
Copy link

wisec commented Nov 28, 2017

Hello I've stumbled in this code example:

let { test:myvar = "default" }= { test: "aValue" };

Escodegen outputs the following code from Esprima AST:

let {
    myvar = 'default': myvar = 'default'
} = { test: 'aValue' };

Which is obviously wrong.
Sample code to reproduce:

var es_parse = require('esprima').parse;
var esgenerate = require('escodegen').generate
var code = 'let { test:myvar = "default" }= { test: "aValue" };';
var ast = es_parse(code);
console.log(esgenerate(ast));

Thanks!

wisec pushed a commit to wisec/escodegen that referenced this issue Nov 29, 2017
@wisec
Copy link
Author

wisec commented Nov 30, 2017

Any feedback?

@bsl-zcs
Copy link

bsl-zcs commented Dec 3, 2017

I've hit this bug with fuse-box bundler which uses acorn parser.

function a({b:c="d"}) { console.log(c) }

produced

function a({
    c = 'd': c = 'd'
}) {
    console.log(c);
}

Your patch fixes it well, thanks! Hope it will be merged and released soon.

@wisec
Copy link
Author

wisec commented Dec 4, 2017

@michaelficarra @Constellation any feedback would be welcome.
Asking this in a bit of a rush because we hope the PR to be approved and get it to mainstream.

Thanks

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

No branches or pull requests

2 participants