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

Array spread with function call broken in 0.2.0 #695

Closed
AshleyScirra opened this issue Sep 21, 2017 · 3 comments
Closed

Array spread with function call broken in 0.2.0 #695

AshleyScirra opened this issue Sep 21, 2017 · 3 comments

Comments

@AshleyScirra
Copy link

AshleyScirra commented Sep 21, 2017

Input Code

function foo()
{
	return [...bar].reverse();
};

Actual Output

function foo() {
	return [...bar]; // oops - where did reverse() go?
}

Expected Output

function foo() {
	return [...bar].reverse();
}

Details

I'd suspect it is reversing the elements in the array literal and removing the reverse() call, but it does not take in to account spread.
Workaround:

function foo()
{
	const ret = [...bar];
	return ret.reverse();
};

This keeps the reverse() call after minify.

@AshleyScirra
Copy link
Author

Related case: babel-minify crashes with this code:

function foo()
{
	return [...bar].pop();
};

(node:13992) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: unknown: Property argument of ReturnStatement expected node to be of a type ["Expression"] but instead got "SpreadElement"

@boopathi
Copy link
Member

Interesting. I suppose this was fixed in #610.
If you spot the bug, feel free the send a PR.

@AshleyScirra
Copy link
Author

#628 also looks related btw.

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