language-javascript
language-javascript copied to clipboard
Fix arrow function body parsing
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
Thanks for the fix, @gabejohnson, I'm encountering the same error. @erikd are there any issues with this being merged?