coerce inferred function name to a valid identifier

This commit is contained in:
Sebastian McKenzie 2015-02-21 14:11:18 +11:00
parent 8065c981dc
commit f6512b45d5

View File

@ -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 () {