Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(994)

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart

Issue 11464026: Diagnose illegal lvalues better. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove dead code Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | dart/tests/language/syntax_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
diff --git a/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart b/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
index 687cec8ea120da5f7377f3b3130f692ef6d4fa79..b557d939d7a8583f82b3fadc0500191326c638bd 100644
--- a/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
+++ b/dart/sdk/lib/_internal/compiler/implementation/scanner/listener.dart
@@ -1337,8 +1337,14 @@ class NodeListener extends ElementListener {
Node receiver = popNode();
String tokenString = token.stringValue;
if (identical(tokenString, '.') || identical(tokenString, '..')) {
- if (argument is !Send) internalError(node: argument);
- if (argument.asSend().receiver != null) internalError(node: argument);
+ Send argumentSend = argument.asSend();
+ if (argumentSend == null) {
+ // TODO(ahe): The parser should diagnose this problem, not
+ // this listener.
+ listener.cancel('Syntax error: Expected an identifier.',
+ node: argument);
+ }
+ if (argumentSend.receiver != null) internalError(node: argument);
if (argument is SendSet) internalError(node: argument);
pushNode(argument.asSend().copyWithReceiver(receiver));
} else {
@@ -1369,8 +1375,9 @@ class NodeListener extends ElementListener {
Node arg = popNode();
Node node = popNode();
Send send = node.asSend();
- if (send == null) internalError(node: node);
- if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send);
+ if (send == null || !(send.isPropertyAccess || send.isIndex)) {
+ reportNotAssignable(node);
+ }
if (send.asSendSet() != null) internalError(node: send);
NodeList arguments;
if (send.isIndex) {
@@ -1384,6 +1391,12 @@ class NodeListener extends ElementListener {
pushNode(new SendSet(send.receiver, send.selector, op, arguments));
}
+ void reportNotAssignable(Node node) {
+ // TODO(ahe): The parser should diagnose this problem, not this
+ // listener.
+ listener.cancel('Syntax error: Not assignable.', node: node);
+ }
+
void handleConditionalExpression(Token question, Token colon) {
Node elseExpression = popNode();
Node thenExpression = popNode();
@@ -1505,8 +1518,12 @@ class NodeListener extends ElementListener {
void handleUnaryAssignmentExpression(Token token, bool isPrefix) {
Node node = popNode();
Send send = node.asSend();
- if (send == null) internalError(node: node);
- if (!(send.isPropertyAccess || send.isIndex)) internalError(node: send);
+ if (send == null) {
+ reportNotAssignable(node);
+ }
+ if (!(send.isPropertyAccess || send.isIndex)) {
+ reportNotAssignable(node);
+ }
if (send.asSendSet() != null) internalError(node: send);
Node argument = null;
if (send.isIndex) argument = send.arguments.head;
@@ -1817,8 +1834,8 @@ class NodeListener extends ElementListener {
void internalError({Token token, Node node}) {
// TODO(ahe): This should call listener.internalError.
- listener.cancel('internal error', token: token, node: node);
- throw 'internal error';
+ Spannable spannable = (token == null) ? node : token;
+ throw new SpannableAssertionFailure(spannable, 'internal error in parser');
}
}
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/compiler.dart ('k') | dart/tests/language/syntax_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698