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

Unified Diff: pkg/analyzer/lib/src/generated/parser.dart

Issue 890253003: Report a compile-time error if async/sync/yield used as an identifier. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/parser.dart
diff --git a/pkg/analyzer/lib/src/generated/parser.dart b/pkg/analyzer/lib/src/generated/parser.dart
index 7ca610b14e57a7fcd2d420c34e5aceab61ec3051..2d94dd0aafff19c4dd7c3edb1a9a053e390a6b6e 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -3674,6 +3674,12 @@ class Parser {
*/
SimpleIdentifier parseSimpleIdentifier() {
if (_matchesIdentifier()) {
+ String lexeme = _currentToken.lexeme;
+ if ((_inAsync || _inGenerator) &&
+ (lexeme == 'async' || lexeme == 'await' || lexeme == 'yield')) {
+ _reportErrorForCurrentToken(
+ ParserErrorCode.ASYNC_KEYWORD_USED_AS_IDENTIFIER);
+ }
return new SimpleIdentifier(getAndAdvance());
}
_reportErrorForCurrentToken(ParserErrorCode.MISSING_IDENTIFIER);
@@ -10029,6 +10035,16 @@ class ParserErrorCode extends ErrorCode {
'ASSERT_DOES_NOT_TAKE_RETHROW',
"Assert cannot be called on rethrows");
+ /**
+ * 16.32 Identifier Reference: It is a compile-time error if any of the
+ * identifiers async, await, or yield is used as an identifier in a function
+ * body marked with either async, async*, or sync*.
+ */
+ static const ParserErrorCode ASYNC_KEYWORD_USED_AS_IDENTIFIER =
+ const ParserErrorCode(
+ 'ASYNC_KEYWORD_USED_AS_IDENTIFIER',
+ "The keywords 'async', 'await', and 'yield' may not be used as identifiers in an asynchronous or generator function.");
+
static const ParserErrorCode BREAK_OUTSIDE_OF_LOOP = const ParserErrorCode(
'BREAK_OUTSIDE_OF_LOOP',
"A break statement cannot be used outside of a loop or switch statement");
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698