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

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

Issue 10917170: Improve handling of built-in identifiers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 months 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
Index: dart/lib/compiler/implementation/scanner/listener.dart
diff --git a/dart/lib/compiler/implementation/scanner/listener.dart b/dart/lib/compiler/implementation/scanner/listener.dart
index b148dcfcf643995fd38926b69805e95783ee3a83..dc727e71d32dc91cd098edd0de15b1916e569545 100644
--- a/dart/lib/compiler/implementation/scanner/listener.dart
+++ b/dart/lib/compiler/implementation/scanner/listener.dart
@@ -608,6 +608,16 @@ class ElementListener extends Listener {
name.source, beginToken, endToken, compilationUnitElement, id);
element.nativeName = nativeName;
pushElement(element);
+ rejectBuiltInIdentifier(name);
+ }
+
+ void rejectBuiltInIdentifier(Identifier name) {
+ if (name.source is Keyword) {
+ Keyword keyword = name.source;
+ if (!keyword.isPseudo) {
+ recoverableError('illegal name ${keyword.syntax}', node: name);
+ }
+ }
}
void endDefaultClause(Token defaultKeyword) {
@@ -631,6 +641,7 @@ class ElementListener extends Listener {
int id = idGenerator();
pushElement(new PartialClassElement(
name.source, interfaceKeyword, endToken, compilationUnitElement, id));
+ rejectBuiltInIdentifier(name);
}
void endFunctionTypeAlias(Token typedefKeyword, Token endToken) {
@@ -639,6 +650,7 @@ class ElementListener extends Listener {
TypeAnnotation returnType = popNode();
pushElement(new PartialTypedefElement(name.source, compilationUnitElement,
typedefKeyword));
+ rejectBuiltInIdentifier(name);
}
void handleVoidKeyword(Token token) {

Powered by Google App Engine
This is Rietveld 408576698