From f0d07e9da1506f2352dfa597539abb8b81ad4e16 Mon Sep 17 00:00:00 2001 From: Matthew W Date: Wed, 16 Dec 2015 21:11:38 +0000 Subject: [PATCH] Correct cases where arrow functions contain deeply nested expressions containing await and logical/conditional operators Fix edge cases in code output (sparse array constants, object pattern precedence, generator member functions), add everything.js syntax tests --- README.md | 5 +++++ lib/arboriculture.js | 29 ++++++++++++++++++----------- package.json | 2 +- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 01968b1..047a732 100644 --- a/README.md +++ b/README.md @@ -736,6 +736,11 @@ The test is a simple set of nested loops calling async functions that don't do m Changelog ========== +16-Dec-15 v2.3.9 + +- Correct cases where arrow functions contain deeply nested expressions containing await and logical/conditional operators +- Fix edge cases in code output (sparse array constants, object pattern precedence, generator member functions), add everything.js syntax tests + 10-Dec-15 v2.3.7 - Correctly asynchronize ES6 `for...in` loops. diff --git a/lib/arboriculture.js b/lib/arboriculture.js index 80da649..f665c07 100644 --- a/lib/arboriculture.js +++ b/lib/arboriculture.js @@ -258,6 +258,18 @@ function asynchronize(pr,__sourceMapping,opts,logger) { return null ; } + function makeArrowFunctionBlock(node) { + if (node.type==='ArrowFunctionExpression' && node.body.type !== 'BlockStatement') { + node.body = { + type: "BlockStatement", + body: [{ + type: "ReturnStatement", + argument: node.body + }] + } ; + } + } + pr.ast = fixSuperReferences(pr.ast) ; if (opts.generators) { pr.ast = asyncSpawn(pr.ast) ; @@ -589,6 +601,7 @@ function asynchronize(pr,__sourceMapping,opts,logger) { } ; node.right = r ; } + var stmt,body ; for (var n=1; n