Closed
Description
Split off from issue #6982. In TypeScript 6b05ad7, which is master as of 19 Feb 2016.
This input:
let x =
/* trivia */ () => 3;
produces the comment twice, with output like:
var x =
/* trivia */
/* trivia */ function () { return 3; }
The end of the call stack at the time of the second emit is (innermost function at the top):
emitFunctionDeclaration (emitter.ts:4537)
emitJavaScriptWorker (emitter.ts:7898)
emitNodeWithoutSourceMap (emitter.ts:7749)
emitNodeWithSourceMap (emitter.ts:7742)
emitNodeConsideringCommentsOption (emitter.ts:7731)
emitNodeConsideringCommentsOption
calls emitLeadingComments
once before calling emitNodeWithSourceMap
(seen here), but then emitFunctionDeclaration
(at the bottom of this stack) itself calls emitLeadingComments
again on the same node.
The code in emitFunctionDeclaration
appears to try to defend against this double-emitting but gets it wrong in this case.