fix crash when multiple params have inline JSDoc comments with no JSDoc tags (#972)

This commit is contained in:
Jeff Williams 2015-03-30 09:56:32 -07:00
parent 3c1f04396b
commit 80c2a9a38c
3 changed files with 19 additions and 2 deletions

View File

@ -85,7 +85,7 @@ function makeInlineParamsFinisher(parser) {
parentDoclet.params = parentDoclet.params || [];
documentedParams = parentDoclet.params;
knownParams = parentDoclet.meta.code.paramnames;
knownParams = parentDoclet.meta.code.paramnames || [];
while (true) {
param = documentedParams[i];
@ -100,7 +100,7 @@ function makeInlineParamsFinisher(parser) {
// splice in the param at the current index
if ( !param || i === knownParams.indexOf(e.doclet.name) ) {
documentedParams.splice(i, 0, {
type: e.doclet.type,
type: e.doclet.type || {},
description: '',
name: e.doclet.name
});

3
test/fixtures/inlineparamcomment.js vendored Normal file
View File

@ -0,0 +1,3 @@
var ns = {
foo: function(/** Number */ a, /** Number */ b) {}
};

View File

@ -0,0 +1,14 @@
'use strict';
describe('inline comments on function parameters', function() {
var docSet;
it('should not crash when multiple parameters have inline comments that do not contain any' +
'JSDoc tags', function() {
function loadDocSet() {
docSet = jasmine.getDocSetFromFile('test/fixtures/inlineparamcomment.js');
}
expect(loadDocSet).not.toThrow();
});
});