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

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

Issue 2821483003: Revert "Fix more parser bugs" (Closed)
Patch Set: Created 3 years, 8 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/parser_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 33eba26d683875fa8ab9bdf729882c49f13f2e89..4810f5221c5098cc85aa58d469fd554ecaf67a6d 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -542,7 +542,7 @@ class Parser {
// There was no type name, so this can't be a declaration.
return false;
}
- while (_atGenericFunctionTypeAfterReturnType(token)) {
+ if (_atGenericFunctionTypeAfterReturnType(token)) {
token = skipGenericFunctionTypeAfterReturnType(token);
if (token == null) {
// There was no type name, so this can't be a declaration.
@@ -4061,22 +4061,24 @@ class Parser {
])) {
return _parseFunctionDeclarationStatementAfterReturnType(
commentAndMetadata, returnType);
- } else if (_matchesIdentifier() &&
- next.matchesAny(const <TokenType>[
- TokenType.EQ,
- TokenType.COMMA,
- TokenType.SEMICOLON
- ])) {
- if (returnType is! GenericFunctionType) {
- _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
- }
- return _parseVariableDeclarationStatementAfterType(
- commentAndMetadata, null, returnType);
} else {
//
// We have found an error of some kind. Try to recover.
//
- if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
+ if (_matchesIdentifier()) {
+ if (next.matchesAny(const <TokenType>[
+ TokenType.EQ,
+ TokenType.COMMA,
+ TokenType.SEMICOLON
+ ])) {
+ //
+ // We appear to have a variable declaration with a type of "void".
+ //
+ _reportErrorForNode(ParserErrorCode.VOID_VARIABLE, returnType);
+ return parseVariableDeclarationStatementAfterMetadata(
+ commentAndMetadata);
+ }
+ } else if (_matches(TokenType.CLOSE_CURLY_BRACKET)) {
//
// We appear to have found an incomplete statement at the end of a
// block. Parse it as a variable declaration.
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698