Permalink
Browse files

fix(function): crash when function is assigned with member expression

  • Loading branch information...
h13i32maru committed Dec 31, 2016
1 parent 333efcb commit e59820aed2f3e2091f32d35de34925d0132630e0
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/Doc/FunctionDoc.js
View
@@ -1,3 +1,4 @@
+import babelGenerator from 'babel-generator';
import AbstractDoc from './AbstractDoc.js';
import ParamParser from '../Parser/ParamParser.js';
import NamingUtil from '../Util/NamingUtil.js';
@@ -18,8 +19,9 @@ export default class FunctionDoc extends AbstractDoc {
if (this._node.id) {
if (this._node.id.type === 'MemberExpression') {
- // todo: can not reproduce this condition.
- // this._value.name = ASTUtil.flattenMemberExpression(this._node.id);
+ // e.g. foo[bar.baz] = function bal(){}
+ const expression = babelGenerator(this._node.id).code;
+ this._value.name = `[${expression}]`;
} else {
this._value.name = this._node.id.name;
}

0 comments on commit e59820a

Please sign in to comment.