protect against replacing a class expression with itself when attempting to infer a new function name - fixes #2803

This commit is contained in:
Sebastian McKenzie
2015-11-04 23:34:33 +00:00
parent 1796b1926c
commit 1bfb7039e9
3 changed files with 5 additions and 1 deletions

View File

@@ -20,7 +20,7 @@ export default function ({ types: t }) {
ClassExpression(path, state) {
let inferred = nameFunction(path);
if (inferred) return path.replaceWith(inferred);
if (inferred && inferred !== path.node) return path.replaceWith(inferred);
let Constructor = VanillaTransformer;
if (state.opts.loose) Constructor = LooseTransformer;