diff --git a/Objective-J/acorn.js b/Objective-J/acorn.js index 320f7743a..8c0a2ee07 100644 --- a/Objective-J/acorn.js +++ b/Objective-J/acorn.js @@ -156,7 +156,7 @@ if (!exports.acorn) { // These are used to hold arrays of comments when // `options.trackComments` is true. - var tokCommentsBefore, tokCommentsAfter; + var tokCommentsBefore, tokCommentsAfter, lastTokCommentsAfter; // These are used to hold arrays of spaces when // `options.trackSpaces` is true. @@ -505,6 +505,7 @@ if (!exports.acorn) { tokType = type; skipSpace(); tokVal = val; + lastTokCommentsAfter = tokCommentsAfter; tokCommentsAfter = tokComments; tokSpacesAfter = tokSpaces; tokRegexpAllowed = type.beforeExpr; @@ -1056,7 +1057,7 @@ if (!exports.acorn) { node.start = other.start; if (other.commentsBefore) { node.commentsBefore = other.commentsBefore; - other.commentsBefore = null; + delete other.commentsBefore; } if (options.locations) { node.loc = new node_loc_t(); @@ -1083,13 +1084,13 @@ if (!exports.acorn) { node.type = type; node.end = lastEnd; if (options.trackComments) { - if (tokCommentsAfter) { - node.commentsAfter = tokCommentsAfter; + if (lastTokCommentsAfter) { + node.commentsAfter = lastTokCommentsAfter; tokCommentsAfter = null; } else if (lastFinishedNode && lastFinishedNode.end === lastEnd && lastFinishedNode.commentsAfter) { node.commentsAfter = lastFinishedNode.commentsAfter; - lastFinishedNode.commentsAfter = null; + delete lastFinishedNode.commentsAfter; } if (!options.trackSpaces) lastFinishedNode = node;