Skip to content

Commit

Permalink
fix(function): crash when function is assigned with member expression
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Dec 31, 2016
1 parent 333efcb commit e59820a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Doc/FunctionDoc.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
}
Expand Down

0 comments on commit e59820a

Please sign in to comment.