diff --git a/acorn_loose.js b/acorn_loose.js index 39157f310e..97a3df603a 100644 --- a/acorn_loose.js +++ b/acorn_loose.js @@ -905,7 +905,12 @@ } } popCx(); - eat(tt.braceR); + if (!eat(tt.braceR)) { + // If there is no closing brace, make the node span to the start + // of the next token (this is useful for Tern) + lastEnd = token.start; + if (options.locations) lastEndLoc = token.startLoc; + } if (isClass) { semicolon(); finishNode(node.body, "ClassBody"); @@ -1152,7 +1157,12 @@ eat(tt.comma); } popCx(); - eat(close); + if (!eat(close)) { + // If there is no closing brace, make the node span to the start + // of the next token (this is useful for Tern) + lastEnd = token.start; + if (options.locations) lastEndLoc = token.startLoc; + } return elts; } });