From f6512b45d592015ed0a09b9b345979e3220d7e8c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 21 Feb 2015 14:11:18 +1100 Subject: [PATCH] coerce inferred function name to a valid identifier --- .../transformation/transformers/spec/function-name.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/babel/transformation/transformers/spec/function-name.js b/lib/babel/transformation/transformers/spec/function-name.js index b0ec5d092d..d52201470b 100644 --- a/lib/babel/transformation/transformers/spec/function-name.js +++ b/lib/babel/transformation/transformers/spec/function-name.js @@ -29,10 +29,13 @@ exports.FunctionExpression = function (node, parent, scope) { if (!t.isIdentifier(id)) return; + var name = t.toIdentifier(id.name); + id = t.identifier(name); + // check to see if we have a local binding of the id we're setting inside of // the function, this is important as there are caveats associated - var bindingInfo = scope.getOwnBindingInfo(id.name); + var bindingInfo = scope.getOwnBindingInfo(name); if (bindingInfo) { if (bindingInfo.type === "param") { @@ -65,11 +68,11 @@ exports.FunctionExpression = function (node, parent, scope) { // - var binding = scope.getBindingIdentifier(id.name); + var binding = scope.getBindingIdentifier(name); var outerId; scope.traverse(node, propertyFunctionVisitor, { - name: id.name, + name: name, binding: binding, getOuter: function () {