language-javascript icon indicating copy to clipboard operation
language-javascript copied to clipboard

Fix arrow function body parsing

Open gabejohnson opened this issue 5 years ago • 1 comments

Fixes #116

The issue with the current parsing rules and representation is that arrow function bodies are not statements, they're either function blocks or expressions. Looking at the specification we see that the expressions are AssignmentExpression in particular.

Making this change fixes the issues mentioned in #116, but breaks minification tests. This turns out not to be a problem, as minification for the cases covered by the failing tests resulted in behavior inconsistent with the non-minified version:

let x = (() => { 42 })(); // not minified, x == undefined

let x=(()=>42)(); // minified before change, x == 42

let x=(()=>{42})(); // minified after change, x == undefined

gabejohnson avatar Jul 04 '20 02:07 gabejohnson

Thanks for the fix, @gabejohnson, I'm encountering the same error. @erikd are there any issues with this being merged?

chrisnevers avatar Nov 24 '20 21:11 chrisnevers