Fix node boundaries for unexpected regular expressions

Closes #33
This commit is contained in:
Marijn Haverbeke
2013-02-28 19:28:20 +01:00
parent 0b10aa2256
commit 38179fd855
2 changed files with 34 additions and 1 deletions

View File

@@ -679,7 +679,8 @@
}
function readToken(forceRegexp) {
tokStart = tokPos;
if (!forceRegexp) tokStart = tokPos;
else tokPos = tokStart + 1;
if (options.locations) tokStartLoc = new line_loc_t;
if (forceRegexp) return readRegexp();
if (tokPos >= inputLen) return finishToken(_eof);

View File

@@ -26097,6 +26097,38 @@ test("foo: 10; foo: 20;", {
]
});
test("if(1)/ foo/", {
type: "Program",
start: 0,
end: 12,
body: [
{
type: "IfStatement",
start: 0,
end: 12,
test: {
type: "Literal",
start: 3,
end: 4,
value: 1,
raw: "1"
},
consequent: {
type: "ExpressionStatement",
start: 5,
end: 12,
expression: {
type: "Literal",
start: 5,
end: 12,
raw: "/ foo/"
}
},
alternate: null
}
]
});
// option tests
test("var a = 1;", {