Bug 1034585 - Sources with BreakStatements can't be parsed correctly, r=past

This commit is contained in:
Victor Porof 2014-07-04 14:54:51 -04:00
Родитель 5ff125e46c
Коммит 715ecc2059
2 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -60,7 +60,13 @@ function test() {
verify("foo = bar", e => e.name == "bar", [1, 6], [1, 9]);
verify("\nfoo\n=\nbar\n", e => e.name == "bar", [4, 0], [4, 3]);
// LabeledStatement and ContinueStatement, because it's 1968 again
// LabeledStatement, BreakStatement and ContinueStatement, because it's 1968 again
verify("foo: bar", e => e.name == "foo", [1, 0], [1, 3]);
verify("\nfoo\n:\nbar\n", e => e.name == "foo", [2, 0], [2, 3]);
verify("foo: for(;;) break foo", e => e.name == "foo", [1, 19], [1, 22]);
verify("\nfoo\n:\nfor(\n;\n;\n)\nbreak\nfoo\n", e => e.name == "foo", [9, 0], [9, 3]);
verify("foo: bar", e => e.name == "foo", [1, 0], [1, 3]);
verify("\nfoo\n:\nbar\n", e => e.name == "foo", [2, 0], [2, 3]);

Просмотреть файл

@ -450,8 +450,8 @@ let ParserHelpers = {
loc.end.column = loc.start.column + aNode.name.length;
return loc;
}
if (parentType == "ContinueStatement") {
// e.g. continue label
if (parentType == "ContinueStatement" || parentType == "BreakStatement") {
// e.g. continue label; or break label;
// The location is unavailable for the identifier node "label".
let loc = Cu.cloneInto(parentLocation, {});
loc.start.line = loc.end.line;