8000 [[FIX]] Tolerate unterminated nullish coalescing · jshint/jshint@ecae54a · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit ecae54a

Browse files
jugglinmikerwaldron
authored andcommitted
[[FIX]] Tolerate unterminated nullish coalescing
1 parent ca06e6a commit ecae54a

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/jshint.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2451,7 +2451,9 @@ var JSHINT = (function() {
24512451
that.left = left;
24522452
var right = that.right = expression(context, 39);
24532453

2454-
if (!right.paren && (right.id === "||" || right.id === "&&")) {
2454+
if (!right) {
2455+
error("E024", state.tokens.next, state.tokens.next.id);
2456+
} else if (!right.paren && (right.id === "||" || right.id === "&&")) {
24552457
error("E024", that.right, that.right.id);
24562458
}
24572459

tests/unit/parser.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10624,3 +10624,26 @@ exports.loneNew = function (test) {
1062410624

1062510625
test.done();
1062610626
};
10627+
10628+
// gh-3560: "Logical nullish assignment (??=) throwing error"
10629+
exports.loneNullishCoalescing = function (test) {
10630+
TestRun(test, "as reported")
10631+
.addError(2, 8, "Expected an identifier and instead saw '='.")
10632+
.addError(2, 10, "Unexpected '(number)'.")
10633+
.addError(2, 8, "Expected an assignment or function call and instead saw an expression.")
10634+
.addError(2, 9, "Missing semicolon.")
10635+
.addError(2, 10, "Expected an assignment or function call and instead saw an expression.")
10636+
.test([
10637+
"let a = [1,2];",
10638+
"a[0] ??= 0;"
10639+
], {esversion: 11});
10640+
10641+
TestRun(test, "simplified")
6146 10642+
.addError(1, 4, "Expected an identifier and instead saw ';'.")
10643+
.addError(1, 4, "Unexpected '(end)'.")
10644+
.addError(1, 4, "Expected an assignment or function call and instead saw an expression.")
10645+
.addError(1, 5, "Missing semicolon.")
10646+
.test("0??;", {esversion: 11});
10647+
10648+
test.done();
10649+
};

0 commit comments

Comments
 (0)
0