Skip to content

Commit

Permalink
[[FIX]] Correct location reported for W043
Browse files Browse the repository at this point in the history
In addition, do not emit the E029 error. Maintain the error code itself
to replace with W043 in a future release.
  • Loading branch information
jugglinmike authored and rwaldron committed Jul 12, 2017
1 parent d3d84ae commit 1d04868
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/lex.js
Expand Up @@ -1203,7 +1203,7 @@ Lexer.prototype = {

if (!allowNewLine) {
// This condition unequivocally describes a syntax error.
// TODO: Re-factor as an "error" (not a "warning").
// TODO: Emit error E029 and remove W112.
this.trigger("warning", {
code: "W112",
line: this.line,
Expand Down Expand Up @@ -1232,12 +1232,6 @@ Lexer.prototype = {
// error and implicitly close it at the EOF point.

if (!this.nextLine(checks)) {
this.trigger("error", {
code: "E029",
line: startLine,
character: startChar
});

return {
type: Token.StringLiteral,
value: value,
Expand Down Expand Up @@ -1278,8 +1272,14 @@ Lexer.prototype = {
allowNewLine = parsed.allowNewLine;
}

value += char;
this.skip(jump);
// If char is the empty string, end of the line has been reached. In
// this case, `this.char` should not be incremented so that warnings
// and errors reported in the subsequent loop iteration have the
// correct character column offset.
if (char !== "") {
value += char;
this.skip(jump);
}
}
}

Expand Down
20 changes: 10 additions & 10 deletions tests/unit/options.js
Expand Up @@ -2066,21 +2066,21 @@ exports.strings = function (test) {
var src = fs.readFileSync(__dirname + '/fixtures/strings.js', 'utf8');

TestRun(test)
.addError(9, "Unclosed string.")
.addError(10, "Unclosed string.")
.addError(15, "Unclosed string.")
.addError(9, "Unclosed string.", {character: 20})
.addError(10, "Unclosed string.", {character: 1})
.addError(15, "Unclosed string.", {character: 1})
.addError(25, "Octal literals are not allowed in strict mode.")
.test(src, { es3: true, multistr: true });

TestRun(test)
.addError(3, "Bad escaping of EOL. Use option multistr if needed.")
.addError(4, "Bad escaping of EOL. Use option multistr if needed.")
.addError(9, "Unclosed string.")
.addError(10, "Unclosed string.")
.addError(14, "Bad escaping of EOL. Use option multistr if needed.")
.addError(15, "Unclosed string.")
.addError(3, "Bad escaping of EOL. Use option multistr if needed.", {character: 21})
.addError(4, "Bad escaping of EOL. Use option multistr if needed.", {character: 2})
.addError(9, "Unclosed string.", {character: 20})
.addError(10, "Unclosed string.", {character: 1})
.addError(14, "Bad escaping of EOL. Use option multistr if needed.", {character: 21})
.addError(15, "Unclosed string.", {character: 1})
.addError(25, "Octal literals are not allowed in strict mode.")
.addError(29, "Bad escaping of EOL. Use option multistr if needed.")
.addError(29, "Bad escaping of EOL. Use option multistr if needed.", {character: 36})
.test(src, { es3: true });

test.done();
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/parser.js
Expand Up @@ -697,7 +697,7 @@ exports.strings = function (test) {
var run = TestRun(test)
.addError(1, "Control character in string: <non-printable>.", {character: 10})
.addError(1, "This character may get silently deleted by one or more browsers.")
.addError(7, "Unclosed string.")
.addError(7, "Unclosed string.", {character: 12})
.addError(7, "Missing semicolon.");
run.test(code, {es3: true});
run.test(code, {}); // es5
Expand Down

0 comments on commit 1d04868

Please sign in to comment.