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

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

Issue 689383005: Fix for issue 20796 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed missed case Created 6 years, 1 month 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 | « pkg/analyzer/lib/src/generated/java_core.dart ('k') | 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 d4001e839c5f58602668194d206d0a0895aaf69c..4c9e738f7a6cfd8b0cf7bed1261c68b2eacc11c8 100644
--- a/pkg/analyzer/lib/src/generated/parser.dart
+++ b/pkg/analyzer/lib/src/generated/parser.dart
@@ -4409,6 +4409,9 @@ class Parser {
}
} else if (_matchesKeyword(Keyword.SUPER)) {
initializers.add(_parseSuperConstructorInvocation());
+ } else if (_matches(TokenType.OPEN_CURLY_BRACKET)
+ || _matches(TokenType.FUNCTION)) {
+ _reportErrorForCurrentToken(ParserErrorCode.MISSING_INITIALIZER, []);
} else {
initializers.add(_parseConstructorFieldInitializer());
}
@@ -4463,6 +4466,15 @@ class Parser {
period = _expect(TokenType.PERIOD);
}
SimpleIdentifier fieldName = parseSimpleIdentifier();
+ if (!_matches(TokenType.EQ)) {
+ _reportErrorForCurrentToken(ParserErrorCode.MISSING_ASSIGNMENT_IN_INITIALIZER, []);
+ return new ConstructorFieldInitializer(
+ keyword,
+ period,
+ fieldName,
+ _createSyntheticToken(TokenType.EQ),
+ _createSyntheticIdentifier());
+ }
Token equals = _expect(TokenType.EQ);
bool wasInInitializer = _inInitializer;
_inInitializer = true;
@@ -8010,6 +8022,11 @@ class ParserErrorCode extends ErrorCode {
static const ParserErrorCode MISSING_ASSIGNABLE_SELECTOR = const ParserErrorCode('MISSING_ASSIGNABLE_SELECTOR', "Missing selector such as \".<identifier>\" or \"[0]\"");
+ static const ParserErrorCode MISSING_ASSIGNMENT_IN_INITIALIZER
+ = const ParserErrorCode(
+ 'MISSING_ASSIGNMENT_IN_INITIALIZER',
+ "Expected an assignment after the field name");
+
static const ParserErrorCode MISSING_CATCH_OR_FINALLY = const ParserErrorCode('MISSING_CATCH_OR_FINALLY', "A try statement must have either a catch or finally clause");
static const ParserErrorCode MISSING_CLASS_BODY = const ParserErrorCode('MISSING_CLASS_BODY', "A class definition must have a body, even if it is empty");
@@ -8020,6 +8037,11 @@ class ParserErrorCode extends ErrorCode {
static const ParserErrorCode MISSING_ENUM_BODY = const ParserErrorCode('MISSING_ENUM_BODY', "An enum definition must have a body with at least one constant name");
+ static const ParserErrorCode MISSING_EXPRESSION_IN_INITIALIZER
+ = const ParserErrorCode(
+ 'MISSING_EXPRESSION_IN_INITIALIZER',
+ "Expected an expression after the assignment operator");
+
static const ParserErrorCode MISSING_EXPRESSION_IN_THROW = const ParserErrorCode('MISSING_EXPRESSION_IN_THROW', "Throw expressions must compute the object to be thrown");
static const ParserErrorCode MISSING_FUNCTION_BODY = const ParserErrorCode('MISSING_FUNCTION_BODY', "A function body must be provided");
@@ -8030,6 +8052,9 @@ class ParserErrorCode extends ErrorCode {
static const ParserErrorCode MISSING_IDENTIFIER = const ParserErrorCode('MISSING_IDENTIFIER', "Expected an identifier");
+ static const ParserErrorCode MISSING_INITIALIZER
+ = const ParserErrorCode('MISSING_INITIALIZER', "Expected an initializer");
+
static const ParserErrorCode MISSING_KEYWORD_OPERATOR = const ParserErrorCode('MISSING_KEYWORD_OPERATOR', "Operator declarations must be preceeded by the keyword 'operator'");
static const ParserErrorCode MISSING_NAME_IN_LIBRARY_DIRECTIVE = const ParserErrorCode('MISSING_NAME_IN_LIBRARY_DIRECTIVE', "Library directives must include a library name");
« no previous file with comments | « pkg/analyzer/lib/src/generated/java_core.dart ('k') | pkg/analyzer/test/generated/parser_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698