Skip to content

Commit 606e850

Browse files
committed
fix recovery on ||= and &&= in dart2js
Bug: #31061 Change-Id: I3f8667d5dab92d256122484a6fc83b3527228085 Reviewed-on: https://dart-review.googlesource.com/12760 Reviewed-by: Johnni Winther <[email protected]>
1 parent b9e6147 commit 606e850

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

pkg/compiler/lib/src/diagnostics/messages.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ enum MessageKind {
424424
UNSUPPORTED_BANG_EQ_EQ,
425425
UNSUPPORTED_EQ_EQ_EQ,
426426
UNSUPPORTED_LITERAL_SYMBOL,
427+
UNSUPPORTED_OPERATOR,
427428
UNSUPPORTED_PREFIX_PLUS,
428429
MISSING_EXPRESSION_IN_THROW,
429430
UNTERMINATED_COMMENT,
@@ -2473,6 +2474,10 @@ main() => A.A = 1;
24732474
"'!==' is not an operator. "
24742475
"Did you mean '#{lhs} != #{rhs}' or '!identical(#{lhs}, #{rhs})'?"),
24752476

2477+
MessageKind.UNSUPPORTED_OPERATOR: const MessageTemplate(
2478+
MessageKind.UNSUPPORTED_OPERATOR,
2479+
"'#{operator}' is not an operator. "),
2480+
24762481
MessageKind.UNSUPPORTED_PREFIX_PLUS: const MessageTemplate(
24772482
MessageKind.UNSUPPORTED_PREFIX_PLUS, "'+' is not a prefix operator. ",
24782483
howToFix: "Try removing '+'.",

pkg/compiler/lib/src/parser/node_listener.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ class NodeListener extends ElementListener {
457457
if (send == null || !(send.isPropertyAccess || send.isIndex)) {
458458
reportNotAssignable(node);
459459
}
460+
var tokenString = token.stringValue;
461+
if (tokenString == '||=' || tokenString == '&&=') {
462+
reporter.reportErrorMessage(reporter.spanFromToken(token),
463+
MessageKind.UNSUPPORTED_OPERATOR, {'operator': tokenString});
464+
pushNode(arg);
465+
return;
466+
}
460467
if (send.asSendSet() != null) internalError(node: send);
461468
NodeList arguments;
462469
if (send.isIndex) {

0 commit comments

Comments
 (0)