| 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");
|
|
|