From 77e05c4edc8432741aa8f9562bad76874e3e7759 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Thu, 10 Jul 2014 18:28:07 +0300 Subject: [PATCH] Fixed XJSEmptyExpression location tracking. --- acorn.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/acorn.js b/acorn.js index 7bed972444..54f2867542 100644 --- a/acorn.js +++ b/acorn.js @@ -2982,11 +2982,27 @@ } function parseXJSEmptyExpression() { - var node = startNode(); if (tokType !== _braceR) { unexpected(); } - return finishNode(node, "XJSEmptyExpression"); + + /** + * XJSEmptyExpression is unique type since it doesn't actually parse anything, + * and so it should start at the end of last read token (left brace) and finish + * at the beginning of the next one (right brace). + */ + + var tmp; + + tmp = tokStart; + tokStart = lastEnd; + lastEnd = tmp; + + tmp = tokStartLoc; + tokStartLoc = lastEndLoc; + lastEndLoc = tmp; + + return finishNode(startNode(), "XJSEmptyExpression"); } function parseXJSExpressionContainer() {