From 54638729261d7bd9de293cde696651611104098b Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 22 Jan 2015 08:15:35 +1100 Subject: [PATCH] optional async transformers should remove their ids - fixes #552 --- CHANGELOG.md | 1 + lib/6to5/transformation/helpers/remap-async-to-generator.js | 6 ++++-- .../transformers/optional/bluebird-coroutines.js | 1 - 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19c07a52fc..38f30c3036 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ _Note: Gaps between patch versions are faulty/broken releases._ * Rewritten constants transformer. * **Bug Fix** * Generators now work flawlessly with any parameter transformers. + * Optional async function transformers should not name their functions. * **New Feature** * New `selfContained` transformer. * New `undeclaredVariableCheck` optional transformer. diff --git a/lib/6to5/transformation/helpers/remap-async-to-generator.js b/lib/6to5/transformation/helpers/remap-async-to-generator.js index 33b6961f47..39541cc0d5 100644 --- a/lib/6to5/transformation/helpers/remap-async-to-generator.js +++ b/lib/6to5/transformation/helpers/remap-async-to-generator.js @@ -20,10 +20,12 @@ module.exports = function (node, callId, scope) { traverse(node, visitor, scope); var call = t.callExpression(callId, [node]); + var id = node.id; + delete node.id; if (t.isFunctionDeclaration(node)) { - var declar = t.variableDeclaration("var", [ - t.variableDeclarator(node.id, call) + var declar = t.variableDeclaration("let", [ + t.variableDeclarator(id, call) ]); declar._blockHoist = true; return declar; diff --git a/lib/6to5/transformation/transformers/optional/bluebird-coroutines.js b/lib/6to5/transformation/transformers/optional/bluebird-coroutines.js index 6d6cf5a514..4d51fdda16 100644 --- a/lib/6to5/transformation/transformers/optional/bluebird-coroutines.js +++ b/lib/6to5/transformation/transformers/optional/bluebird-coroutines.js @@ -10,7 +10,6 @@ exports.manipulateOptions = function (opts) { exports.optional = true; - exports.Function = function (node, parent, scope, context, file) { if (!node.async || node.generator) return;