[parser] Empty record types, record types with 1 element

This should bring parsing of record types up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Also fixes https://github.com/dart-lang/sdk/issues/49826

Change-Id: I3737a72ddee49a957bd55f86cc200fb77f23e2a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen
2022-08-30 11:04:10 +00:00
committed by Commit Bot
parent a4352d09e1
commit cec94a1446
34 changed files with 516 additions and 392 deletions
@@ -2881,17 +2881,6 @@ const MessageCode messageEmptyOptionalParameterList = const MessageCode(
problemMessage: r"""Optional parameter lists cannot be empty.""",
correctionMessage: r"""Try adding an optional parameter to the list.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeEmptyRecordTypeFieldsList =
messageEmptyRecordTypeFieldsList;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageEmptyRecordTypeFieldsList = const MessageCode(
"EmptyRecordTypeFieldsList",
analyzerCodes: <String>["MISSING_IDENTIFIER"],
problemMessage: r"""Record type fields list cannot be empty.""",
correctionMessage: r"""Try adding a record type field to the list.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeEmptyRecordTypeNamedFieldsList =
messageEmptyRecordTypeNamedFieldsList;
@@ -2899,8 +2888,8 @@ const Code<Null> codeEmptyRecordTypeNamedFieldsList =
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageEmptyRecordTypeNamedFieldsList = const MessageCode(
"EmptyRecordTypeNamedFieldsList",
analyzerCodes: <String>["MISSING_IDENTIFIER"],
problemMessage: r"""Record type named fields list cannot be empty.""",
index: 129,
problemMessage: r"""Record type named fields list can't be empty.""",
correctionMessage:
r"""Try adding a record type named field to the list.""");
@@ -9124,19 +9113,6 @@ const Code<Null> codeObjectMixesIn = messageObjectMixesIn;
const MessageCode messageObjectMixesIn = const MessageCode("ObjectMixesIn",
problemMessage: r"""The class 'Object' can't use mixins.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeOnlyOneRecordTypeFieldsList =
messageOnlyOneRecordTypeFieldsList;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageOnlyOneRecordTypeFieldsList = const MessageCode(
"OnlyOneRecordTypeFieldsList",
analyzerCodes: <String>["MISSING_IDENTIFIER"],
problemMessage:
r"""Record type fields list cannot contain only one element without a named field.""",
correctionMessage:
r"""Try adding another record type field to the list or add a named field.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeOnlyTry = messageOnlyTry;
@@ -9934,7 +9910,19 @@ const MessageCode messageRecordLiteralOnePositionalFieldNoTrailingComma =
const MessageCode("RecordLiteralOnePositionalFieldNoTrailingComma",
index: 127,
problemMessage:
r"""Record literal with one entry requires a trailing comma.""",
r"""Record literal with one field requires a trailing comma.""",
correctionMessage: r"""Try adding a trailing comma.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeRecordTypeOnePositionalFieldNoTrailingComma =
messageRecordTypeOnePositionalFieldNoTrailingComma;
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageRecordTypeOnePositionalFieldNoTrailingComma =
const MessageCode("RecordTypeOnePositionalFieldNoTrailingComma",
index: 130,
problemMessage:
r"""Record type with one entry requires a trailing comma.""",
correctionMessage: r"""Try adding a trailing comma.""");
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
@@ -1394,6 +1394,7 @@ class Parser {
/// parameterCount counting the presence of named fields as 1.
int parameterCount = 0;
bool hasNamedFields = false;
bool sawComma = false;
while (true) {
Token next = token.next!;
if (optional(')', next)) {
@@ -1436,15 +1437,17 @@ class Parser {
}
}
break;
} else {
sawComma = true;
}
token = next;
}
assert(optional(')', token));
if (parameterCount == 0) {
reportRecoverableError(token, codes.messageEmptyRecordTypeFieldsList);
} else if (parameterCount == 1 && !hasNamedFields) {
reportRecoverableError(token, codes.messageOnlyOneRecordTypeFieldsList);
if (parameterCount == 1 && !hasNamedFields && !sawComma) {
// Single non-named element without trailing comma.
reportRecoverableError(
token, codes.messageRecordTypeOnePositionalFieldNoTrailingComma);
}
Token? questionMark = token.next!;
@@ -769,6 +769,7 @@ class ComplexTypeInfo implements TypeInfo {
Token token, final Token endGroup) {
int parameterCount = 0;
bool hasNamedFields = false;
bool hasComma = false;
while (true) {
Token next = token.next!;
if (optional(')', next)) {
@@ -815,13 +816,14 @@ class ComplexTypeInfo implements TypeInfo {
return;
}
break;
} else {
hasComma = true;
}
token = next;
}
if (!recovered &&
(parameterCount == 0 ||
(parameterCount == 1 && !hasNamedFields) ||
((parameterCount == 1 && !hasNamedFields && !hasComma) ||
token != endGroup)) {
recovered = true;
return;
@@ -2107,6 +2107,8 @@ ParserErrorCode.EMPTY_ENUM_BODY:
notes: |-
We can't guess at the names or number of the enum constants that should be
added.
ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST:
status: needsEvaluation
ParserErrorCode.ENUM_IN_CLASS:
status: needsEvaluation
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND:
@@ -2385,6 +2387,8 @@ ParserErrorCode.RECORD_LITERAL_EMPTY:
status: needsEvaluation
ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA:
status: needsEvaluation
ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA:
status: needsEvaluation
ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY:
status: needsEvaluation
ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR:
+2
View File
@@ -747,6 +747,7 @@ const List<ErrorCode> errorCodeValues = [
ParserErrorCode.DUPLICATE_PREFIX,
ParserErrorCode.DUPLICATED_MODIFIER,
ParserErrorCode.EMPTY_ENUM_BODY,
ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST,
ParserErrorCode.ENUM_IN_CLASS,
ParserErrorCode.EQUALITY_CANNOT_BE_EQUALITY_OPERAND,
ParserErrorCode.EXPECTED_BODY,
@@ -886,6 +887,7 @@ const List<ErrorCode> errorCodeValues = [
ParserErrorCode.PREFIX_AFTER_COMBINATOR,
ParserErrorCode.RECORD_LITERAL_EMPTY,
ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA,
ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA,
ParserErrorCode.REDIRECTING_CONSTRUCTOR_WITH_BODY,
ParserErrorCode.REDIRECTION_IN_NON_FACTORY_CONSTRUCTOR,
ParserErrorCode.SETTER_CONSTRUCTOR,
@@ -143,6 +143,8 @@ final fastaAnalyzerErrorCodes = <ErrorCode?>[
ParserErrorCode.INVALID_UNICODE_ESCAPE_STARTED,
ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA,
ParserErrorCode.RECORD_LITERAL_EMPTY,
ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST,
ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA,
];
class ParserErrorCode extends ErrorCode {
@@ -433,6 +435,13 @@ class ParserErrorCode extends ErrorCode {
correctionMessage: "Try declaring a constant.",
);
static const ParserErrorCode EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST =
ParserErrorCode(
'EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST',
"Record type named fields list can't be empty.",
correctionMessage: "Try adding a record type named field to the list.",
);
static const ParserErrorCode ENUM_IN_CLASS = ParserErrorCode(
'ENUM_IN_CLASS',
"Enums can't be declared inside classes.",
@@ -1392,7 +1401,14 @@ class ParserErrorCode extends ErrorCode {
static const ParserErrorCode RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA =
ParserErrorCode(
'RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA',
"Record literal with one entry requires a trailing comma.",
"Record literal with one field requires a trailing comma.",
correctionMessage: "Try adding a trailing comma.",
);
static const ParserErrorCode RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA =
ParserErrorCode(
'RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA',
"Record type with one entry requires a trailing comma.",
correctionMessage: "Try adding a trailing comma.",
);
@@ -785,7 +785,6 @@ RecordLiteral
''');
}
@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/49826')
void test_recordTypeAnnotation_empty() {
var parseResult = parseStringWithErrors(r'''
() f() {}
+10 -18
View File
@@ -324,7 +324,7 @@ EmptyNamedParameterList:
}
RecordLiteralOnePositionalFieldNoTrailingComma:
problemMessage: "Record literal with one entry requires a trailing comma."
problemMessage: "Record literal with one field requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 127
@@ -345,34 +345,26 @@ RecordLiteralEmpty:
var record = const ();
}
EmptyRecordTypeFieldsList:
problemMessage: "Record type fields list cannot be empty."
correctionMessage: "Try adding a record type field to the list."
analyzerCode: "MISSING_IDENTIFIER"
experiments: records
script: >
main() {
(/*missing*/) record = ((1, 2,) as dynamic);
}
EmptyRecordTypeNamedFieldsList:
problemMessage: "Record type named fields list cannot be empty."
problemMessage: "Record type named fields list can't be empty."
correctionMessage: "Try adding a record type named field to the list."
analyzerCode: "MISSING_IDENTIFIER"
analyzerCode: ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST
index: 129
experiments: records
script: >
main() {
(int, int, {/*missing*/}) record = (1, 2,);
}
OnlyOneRecordTypeFieldsList:
problemMessage: "Record type fields list cannot contain only one element without a named field."
correctionMessage: "Try adding another record type field to the list or add a named field."
analyzerCode: "MISSING_IDENTIFIER"
RecordTypeOnePositionalFieldNoTrailingComma:
problemMessage: "Record type with one entry requires a trailing comma."
correctionMessage: "Try adding a trailing comma."
analyzerCode: ParserErrorCode.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA
index: 130
experiments: records
script: >
main() {
(int /*missing*/) record = ((1, 2,) as dynamic);
(int /* missing trailing comma */) record = const (1, );
}
DuplicatedRecordTypeFieldName:
@@ -4,7 +4,7 @@ parser/error_recovery/issue_26073:3:16: Expected 'Function' before this.
typedef c = foo(int x); // error.
^
parser/error_recovery/issue_26073:4:19: Record type fields list cannot contain only one element without a named field.
parser/error_recovery/issue_26073:4:19: Record type with one entry requires a trailing comma.
typedef d = (int x); // error.
^
@@ -122,7 +122,7 @@ beginCompilationUnit(typedef)
handleType(int, null)
handleIdentifier(x, recordFieldDeclaration)
endRecordTypeEntry()
handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
endRecordType((, null, 1, false)
endTypedef(typedef, =, ;)
endTopLevelDeclaration(typedef)
@@ -137,8 +137,8 @@ parseUnit(typedef)
ensureIdentifier(int, recordFieldDeclaration)
listener: handleIdentifier(x, recordFieldDeclaration)
listener: endRecordTypeEntry()
reportRecoverableError(), OnlyOneRecordTypeFieldsList)
listener: handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
reportRecoverableError(), RecordTypeOnePositionalFieldNoTrailingComma)
listener: handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
listener: endRecordType((, null, 1, false)
ensureSemicolon())
listener: endTypedef(typedef, =, ;)
@@ -56,7 +56,7 @@ parser/error_recovery/keyword_named_class_methods:47:7: 'const' can't be used as
int const(int x) {
^^^^^
parser/error_recovery/keyword_named_class_methods:49:21: Record literal with one entry requires a trailing comma.
parser/error_recovery/keyword_named_class_methods:49:21: Record literal with one field requires a trailing comma.
return const(x-1) + 1;
^
@@ -272,7 +272,7 @@ parser/error_recovery/keyword_named_class_methods:184:16: Expected ')' before th
return is(x-1) + 1;
^
parser/error_recovery/keyword_named_class_methods:184:18: Record type fields list cannot contain only one element without a named field.
parser/error_recovery/keyword_named_class_methods:184:18: Record type with one entry requires a trailing comma.
return is(x-1) + 1;
^
@@ -2773,7 +2773,7 @@ beginCompilationUnit(class)
handleNoName(-)
endRecordTypeEntry()
handleRecoverableError(Message[ExpectedButGot, Expected ')' before this., null, {string: )}], -, -)
handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
endRecordType((, null, 1, false)
endIsOperatorType(is)
handleIsOperator(is, null)
@@ -5741,8 +5741,8 @@ parseUnit(class)
ensureCloseParen(x, ()
reportRecoverableError(-, Message[ExpectedButGot, Expected ')' before this., null, {string: )}])
listener: handleRecoverableError(Message[ExpectedButGot, Expected ')' before this., null, {string: )}], -, -)
reportRecoverableError(), OnlyOneRecordTypeFieldsList)
listener: handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
reportRecoverableError(), RecordTypeOnePositionalFieldNoTrailingComma)
listener: handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
listener: endRecordType((, null, 1, false)
listener: endIsOperatorType(is)
listener: handleIsOperator(is, null)
@@ -56,7 +56,7 @@ parser/error_recovery/keyword_named_top_level_methods:46:5: 'const' can't be use
int const(int x) {
^^^^^
parser/error_recovery/keyword_named_top_level_methods:48:19: Record literal with one entry requires a trailing comma.
parser/error_recovery/keyword_named_top_level_methods:48:19: Record literal with one field requires a trailing comma.
return const(x-1) + 1;
^
@@ -272,7 +272,7 @@ parser/error_recovery/keyword_named_top_level_methods:183:14: Expected ')' befor
return is(x-1) + 1;
^
parser/error_recovery/keyword_named_top_level_methods:183:16: Record type fields list cannot contain only one element without a named field.
parser/error_recovery/keyword_named_top_level_methods:183:16: Record type with one entry requires a trailing comma.
return is(x-1) + 1;
^
@@ -2708,7 +2708,7 @@ beginCompilationUnit(int)
handleNoName(-)
endRecordTypeEntry()
handleRecoverableError(Message[ExpectedButGot, Expected ')' before this., null, {string: )}], -, -)
handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
endRecordType((, null, 1, false)
endIsOperatorType(is)
handleIsOperator(is, null)
@@ -5569,8 +5569,8 @@ parseUnit(int)
ensureCloseParen(x, ()
reportRecoverableError(-, Message[ExpectedButGot, Expected ')' before this., null, {string: )}])
listener: handleRecoverableError(Message[ExpectedButGot, Expected ')' before this., null, {string: )}], -, -)
reportRecoverableError(), OnlyOneRecordTypeFieldsList)
listener: handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
reportRecoverableError(), RecordTypeOnePositionalFieldNoTrailingComma)
listener: handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
listener: endRecordType((, null, 1, false)
listener: endIsOperatorType(is)
listener: handleIsOperator(is, null)
@@ -102,38 +102,35 @@ beginCompilationUnit(void)
handleNoTypeArguments(()
beginArguments(()
handleIdentifier(x, expression)
handleNoTypeArguments(<)
handleNoArguments(<)
handleSend(x, <)
beginBinaryExpression(<)
handleIdentifier(y, expression)
beginTypeArguments(<)
handleIdentifier(y, typeReference)
handleNoTypeArguments(,)
handleNoArguments(,)
handleSend(y, ,)
endBinaryExpression(<)
beginParenthesizedExpressionOrRecordLiteral(()
beginAwaitExpression(await)
handleIdentifier(o, expression)
handleNoTypeArguments(,)
handleNoArguments(,)
handleSend(o, ,)
endAwaitExpression(await, ,)
endRecordLiteral((, 1, null)
beginBinaryExpression(>)
beginParenthesizedExpressionOrRecordLiteral(()
handleIdentifier(p, expression)
handleNoTypeArguments(as)
handleNoArguments(as)
handleSend(p, as)
beginAsOperatorType(as)
handleIdentifier(int, typeReference)
handleNoTypeArguments())
handleType(int, null)
endAsOperatorType(as)
handleAsOperator(as)
endParenthesizedExpression(()
endBinaryExpression(>)
endArguments(2, (, ))
handleType(y, null)
beginRecordType(()
beginRecordTypeEntry()
beginMetadataStar(await)
endMetadataStar(0)
handleIdentifier(await, typeReference)
handleNoTypeArguments(o)
handleType(await, null)
handleIdentifier(o, recordFieldDeclaration)
endRecordTypeEntry()
endRecordType((, null, 1, false)
endTypeArguments(2, <, >)
beginArguments(()
handleIdentifier(p, expression)
handleNoTypeArguments(as)
handleNoArguments(as)
handleSend(p, as)
beginAsOperatorType(as)
handleIdentifier(int, typeReference)
handleNoTypeArguments())
handleType(int, null)
endAsOperatorType(as)
handleAsOperator(as)
endArguments(1, (, ))
handleSend(x, ))
endArguments(1, (, ))
handleSend(f, ;)
handleExpressionStatement(;)
endBlockFunctionBody(1, {, })
@@ -212,86 +212,54 @@ parseUnit(void)
isNextIdentifier(()
ensureIdentifier((, expression)
listener: handleIdentifier(x, expression)
listener: handleNoTypeArguments(<)
parseArgumentsOpt(x)
listener: handleNoArguments(<)
listener: handleSend(x, <)
listener: beginBinaryExpression(<)
parsePrecedenceExpression(<, 9, true)
parseUnaryExpression(<, true)
parsePrimary(<, expression)
parseSendOrFunctionLiteral(<, expression)
parseSend(<, expression)
isNextIdentifier(<)
ensureIdentifier(<, expression)
listener: handleIdentifier(y, expression)
listener: handleNoTypeArguments(,)
parseArgumentsOpt(y)
listener: handleNoArguments(,)
listener: handleSend(y, ,)
listener: endBinaryExpression(<)
parseExpression(,)
parsePrecedenceExpression(,, 1, true)
parseUnaryExpression(,, true)
parsePrimary(,, expression)
parseParenthesizedExpressionFunctionLiteralOrRecordLiteral(,)
parseParenthesizedExpressionOrRecordLiteral(,, null)
listener: beginParenthesizedExpressionOrRecordLiteral(()
parseExpression(()
parsePrecedenceExpression((, 1, true)
parseUnaryExpression((, true)
inPlainSync()
parseAwaitExpression((, true)
listener: beginAwaitExpression(await)
parsePrecedenceExpression(await, 16, true)
parseUnaryExpression(await, true)
parsePrimary(await, expression)
parseSendOrFunctionLiteral(await, expression)
parseSend(await, expression)
isNextIdentifier(await)
ensureIdentifier(await, expression)
listener: handleIdentifier(o, expression)
listener: handleNoTypeArguments(,)
parseArgumentsOpt(o)
listener: handleNoArguments(,)
listener: handleSend(o, ,)
inAsync()
listener: endAwaitExpression(await, ,)
ensureCloseParen(,, ()
listener: endRecordLiteral((, 1, null)
listener: beginBinaryExpression(>)
parsePrecedenceExpression(>, 9, true)
parseUnaryExpression(>, true)
parsePrimary(>, expression)
parseParenthesizedExpressionFunctionLiteralOrRecordLiteral(>)
parseParenthesizedExpressionOrRecordLiteral(>, null)
listener: beginParenthesizedExpressionOrRecordLiteral(()
parseExpression(()
parsePrecedenceExpression((, 1, true)
parseUnaryExpression((, true)
parsePrimary((, expression)
parseSendOrFunctionLiteral((, expression)
parseSend((, expression)
isNextIdentifier(()
ensureIdentifier((, expression)
listener: handleIdentifier(p, expression)
listener: handleNoTypeArguments(as)
parseArgumentsOpt(p)
listener: handleNoArguments(as)
listener: handleSend(p, as)
parseAsOperatorRest(p)
listener: beginAsOperatorType(as)
computeTypeAfterIsOrAs(as)
listener: handleIdentifier(int, typeReference)
listener: handleNoTypeArguments())
listener: handleType(int, null)
listener: endAsOperatorType(as)
listener: handleAsOperator(as)
skipChainedAsIsOperators(int)
ensureCloseParen(int, ()
listener: endParenthesizedExpression(()
listener: endBinaryExpression(>)
listener: endArguments(2, (, ))
listener: beginTypeArguments(<)
listener: handleIdentifier(y, typeReference)
listener: handleNoTypeArguments(,)
listener: handleType(y, null)
parseRecordType((, ,)
listener: beginRecordType(()
parseRecordTypeField((, identifierIsOptional: true)
listener: beginRecordTypeEntry()
parseMetadataStar(()
listener: beginMetadataStar(await)
listener: endMetadataStar(0)
listener: handleIdentifier(await, typeReference)
listener: handleNoTypeArguments(o)
listener: handleType(await, null)
ensureIdentifier(await, recordFieldDeclaration)
listener: handleIdentifier(o, recordFieldDeclaration)
listener: endRecordTypeEntry()
listener: endRecordType((, null, 1, false)
listener: endTypeArguments(2, <, >)
parseArgumentsOpt(>)
parseArguments(>)
parseArgumentsRest(()
listener: beginArguments(()
parseExpression(()
parsePrecedenceExpression((, 1, true)
parseUnaryExpression((, true)
parsePrimary((, expression)
parseSendOrFunctionLiteral((, expression)
parseSend((, expression)
isNextIdentifier(()
ensureIdentifier((, expression)
listener: handleIdentifier(p, expression)
listener: handleNoTypeArguments(as)
parseArgumentsOpt(p)
listener: handleNoArguments(as)
listener: handleSend(p, as)
parseAsOperatorRest(p)
listener: beginAsOperatorType(as)
computeTypeAfterIsOrAs(as)
listener: handleIdentifier(int, typeReference)
listener: handleNoTypeArguments())
listener: handleType(int, null)
listener: endAsOperatorType(as)
listener: handleAsOperator(as)
skipChainedAsIsOperators(int)
listener: endArguments(1, (, ))
listener: handleSend(x, ))
listener: endArguments(1, (, ))
listener: handleSend(f, ;)
ensureSemicolon())
listener: handleExpressionStatement(;)
@@ -1,6 +1,6 @@
Problems reported:
parser/record/record_literal_04:9:21: Record literal with one entry requires a trailing comma.
parser/record/record_literal_04:9:21: Record literal with one field requires a trailing comma.
var r5 = const (42);
^
@@ -1,6 +1,10 @@
void foo() {
void errors() {
(int, int, {/*missing*/}) record1 = (1, 2);
(int /* missing */ ) record2 = (1);
({int ok}) record3 = (ok: 1);
(/*missing*/) record4 = ();
(int /* missing trailing comma */ ) record2 = (1, );
}
void ok() {
(int, ) record1 = (1, );
({int ok}) record2 = (ok: 1);
() record3 = Record.empty;
}
@@ -1,20 +1,12 @@
Problems reported:
parser/record/record_type_02:2:26: Record type named fields list cannot be empty.
parser/record/record_type_02:2:26: Record type named fields list can't be empty.
(int, int, {/*missing*/}) record1 = (1, 2);
^
parser/record/record_type_02:3:22: Record type fields list cannot contain only one element without a named field.
(int /* missing */ ) record2 = (1);
^
parser/record/record_type_02:5:15: Record type fields list cannot be empty.
(/*missing*/) record4 = ();
^
parser/record/record_type_02:5:28: Expected an identifier, but got ')'.
(/*missing*/) record4 = ();
^
parser/record/record_type_02:3:37: Record type with one entry requires a trailing comma.
(int /* missing trailing comma */ ) record2 = (1, );
^
beginCompilationUnit(void)
beginMetadataStar(void)
@@ -22,7 +14,7 @@ beginCompilationUnit(void)
beginTopLevelMember(void)
beginTopLevelMethod(, null, null)
handleVoidKeyword(void)
handleIdentifier(foo, topLevelFunctionDeclaration)
handleIdentifier(errors, topLevelFunctionDeclaration)
handleNoTypeVariables(()
beginFormalParameters((, MemberKind.TopLevelMethod)
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
@@ -73,7 +65,7 @@ beginCompilationUnit(void)
handleType(int, null)
handleNoName())
endRecordTypeEntry()
handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
endRecordType((, null, 1, false)
beginVariablesDeclaration(record2, null, null)
handleIdentifier(record2, localVariableDeclaration)
@@ -81,10 +73,46 @@ beginCompilationUnit(void)
beginVariableInitializer(=)
beginParenthesizedExpressionOrRecordLiteral(()
handleLiteralInt(1)
endParenthesizedExpression(()
endRecordLiteral((, 1, null)
endVariableInitializer(=)
endInitializedIdentifier(record2)
endVariablesDeclaration(1, ;)
endBlockFunctionBody(2, {, })
endTopLevelMethod(void, null, })
endTopLevelDeclaration(void)
beginMetadataStar(void)
endMetadataStar(0)
beginTopLevelMember(void)
beginTopLevelMethod(}, null, null)
handleVoidKeyword(void)
handleIdentifier(ok, topLevelFunctionDeclaration)
handleNoTypeVariables(()
beginFormalParameters((, MemberKind.TopLevelMethod)
endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
handleAsyncModifier(null, null)
beginBlockFunctionBody({)
beginMetadataStar(()
endMetadataStar(0)
beginRecordType(()
beginRecordTypeEntry()
beginMetadataStar(int)
endMetadataStar(0)
handleIdentifier(int, typeReference)
handleNoTypeArguments(,)
handleType(int, null)
handleNoName(,)
endRecordTypeEntry()
endRecordType((, null, 1, false)
beginVariablesDeclaration(record1, null, null)
handleIdentifier(record1, localVariableDeclaration)
beginInitializedIdentifier(record1)
beginVariableInitializer(=)
beginParenthesizedExpressionOrRecordLiteral(()
handleLiteralInt(1)
endRecordLiteral((, 1, null)
endVariableInitializer(=)
endInitializedIdentifier(record1)
endVariablesDeclaration(1, ;)
beginMetadataStar(()
endMetadataStar(0)
beginRecordType(()
@@ -99,9 +127,9 @@ beginCompilationUnit(void)
endRecordTypeEntry()
endRecordTypeNamedFields(1, {)
endRecordType((, null, 1, true)
beginVariablesDeclaration(record3, null, null)
handleIdentifier(record3, localVariableDeclaration)
beginInitializedIdentifier(record3)
beginVariablesDeclaration(record2, null, null)
handleIdentifier(record2, localVariableDeclaration)
beginInitializedIdentifier(record2)
beginVariableInitializer(=)
beginParenthesizedExpressionOrRecordLiteral(()
handleIdentifier(ok, namedRecordFieldReference)
@@ -109,28 +137,29 @@ beginCompilationUnit(void)
handleNamedRecordField(:)
endRecordLiteral((, 1, null)
endVariableInitializer(=)
endInitializedIdentifier(record3)
endInitializedIdentifier(record2)
endVariablesDeclaration(1, ;)
beginMetadataStar(()
endMetadataStar(0)
beginRecordType(()
handleRecoverableError(EmptyRecordTypeFieldsList, ), ))
endRecordType((, null, 0, false)
beginVariablesDeclaration(record4, null, null)
handleIdentifier(record4, localVariableDeclaration)
beginInitializedIdentifier(record4)
beginVariablesDeclaration(record3, null, null)
handleIdentifier(record3, localVariableDeclaration)
beginInitializedIdentifier(record3)
beginVariableInitializer(=)
beginParenthesizedExpressionOrRecordLiteral(()
handleRecoverableError(Message[ExpectedIdentifier, Expected an identifier, but got ')'., Try inserting an identifier before ')'., {lexeme: )}], ), ))
handleIdentifier(, expression)
handleNoTypeArguments())
handleNoArguments())
handleSend(, ))
endParenthesizedExpression(()
handleIdentifier(Record, expression)
handleNoTypeArguments(.)
handleNoArguments(.)
handleSend(Record, .)
handleIdentifier(empty, expressionContinuation)
handleNoTypeArguments(;)
handleNoArguments(;)
handleSend(empty, ;)
handleEndingBinaryExpression(.)
endVariableInitializer(=)
endInitializedIdentifier(record4)
endInitializedIdentifier(record3)
endVariablesDeclaration(1, ;)
endBlockFunctionBody(4, {, })
endBlockFunctionBody(3, {, })
endTopLevelMethod(void, null, })
endTopLevelDeclaration()
endCompilationUnit(1, )
endCompilationUnit(2, )
@@ -8,15 +8,15 @@ parseUnit(void)
listener: endMetadataStar(0)
parseTopLevelMemberImpl()
listener: beginTopLevelMember(void)
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, foo, false)
parseTopLevelMethod(, null, null, , Instance of 'VoidType', null, errors, false)
listener: beginTopLevelMethod(, null, null)
listener: handleVoidKeyword(void)
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false)
listener: handleIdentifier(foo, topLevelFunctionDeclaration)
parseMethodTypeVar(foo)
listener: handleIdentifier(errors, topLevelFunctionDeclaration)
parseMethodTypeVar(errors)
listener: handleNoTypeVariables(()
parseGetterOrFormalParameters(foo, foo, false, MemberKind.TopLevelMethod)
parseFormalParameters(foo, MemberKind.TopLevelMethod)
parseGetterOrFormalParameters(errors, errors, false, MemberKind.TopLevelMethod)
parseFormalParameters(errors, MemberKind.TopLevelMethod)
parseFormalParametersRest((, MemberKind.TopLevelMethod)
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
@@ -115,8 +115,8 @@ parseUnit(void)
listener: handleType(int, null)
listener: handleNoName())
listener: endRecordTypeEntry()
reportRecoverableError(), OnlyOneRecordTypeFieldsList)
listener: handleRecoverableError(OnlyOneRecordTypeFieldsList, ), ))
reportRecoverableError(), RecordTypeOnePositionalFieldNoTrailingComma)
listener: handleRecoverableError(RecordTypeOnePositionalFieldNoTrailingComma, ), ))
listener: endRecordType((, null, 1, false)
listener: beginVariablesDeclaration(record2, null, null)
parseVariablesDeclarationRest(), true)
@@ -139,18 +139,93 @@ parseUnit(void)
parsePrimary((, expression)
parseLiteralInt(()
listener: handleLiteralInt(1)
ensureCloseParen(1, ()
listener: endParenthesizedExpression(()
ensureCloseParen(,, ()
listener: endRecordLiteral((, 1, null)
listener: endVariableInitializer(=)
listener: endInitializedIdentifier(record2)
ensureSemicolon())
listener: endVariablesDeclaration(1, ;)
notEofOrValue(}, })
listener: endBlockFunctionBody(2, {, })
listener: endTopLevelMethod(void, null, })
listener: endTopLevelDeclaration(void)
parseTopLevelDeclarationImpl(}, Instance of 'DirectiveContext')
parseMetadataStar(})
listener: beginMetadataStar(void)
listener: endMetadataStar(0)
parseTopLevelMemberImpl(})
listener: beginTopLevelMember(void)
parseTopLevelMethod(}, null, null, }, Instance of 'VoidType', null, ok, false)
listener: beginTopLevelMethod(}, null, null)
listener: handleVoidKeyword(void)
ensureIdentifierPotentiallyRecovered(void, topLevelFunctionDeclaration, false)
listener: handleIdentifier(ok, topLevelFunctionDeclaration)
parseMethodTypeVar(ok)
listener: handleNoTypeVariables(()
parseGetterOrFormalParameters(ok, ok, false, MemberKind.TopLevelMethod)
parseFormalParameters(ok, MemberKind.TopLevelMethod)
parseFormalParametersRest((, MemberKind.TopLevelMethod)
listener: beginFormalParameters((, MemberKind.TopLevelMethod)
listener: endFormalParameters(0, (, ), MemberKind.TopLevelMethod)
parseAsyncModifierOpt())
listener: handleAsyncModifier(null, null)
inPlainSync()
parseFunctionBody(), false, false)
listener: beginBlockFunctionBody({)
notEofOrValue(}, ()
parseStatement({)
parseStatementX({)
parseExpressionStatementOrDeclaration({, false)
parseExpressionStatementOrDeclarationAfterModifiers({, {, null, null, null, false)
looksLikeLocalFunction(record1)
listener: beginMetadataStar(()
listener: endMetadataStar(0)
parseRecordType((, {)
listener: beginRecordType(()
parseRecordTypeField((, identifierIsOptional: true)
listener: beginRecordTypeEntry()
parseMetadataStar(()
listener: beginMetadataStar(int)
listener: endMetadataStar(0)
listener: handleIdentifier(int, typeReference)
listener: handleNoTypeArguments(,)
listener: handleType(int, null)
listener: handleNoName(,)
listener: endRecordTypeEntry()
listener: endRecordType((, null, 1, false)
listener: beginVariablesDeclaration(record1, null, null)
parseVariablesDeclarationRest(), true)
parseOptionallyInitializedIdentifier())
ensureIdentifier(), localVariableDeclaration)
listener: handleIdentifier(record1, localVariableDeclaration)
listener: beginInitializedIdentifier(record1)
parseVariableInitializerOpt(record1)
listener: beginVariableInitializer(=)
parseExpression(=)
parsePrecedenceExpression(=, 1, true)
parseUnaryExpression(=, true)
parsePrimary(=, expression)
parseParenthesizedExpressionFunctionLiteralOrRecordLiteral(=)
parseParenthesizedExpressionOrRecordLiteral(=, null)
listener: beginParenthesizedExpressionOrRecordLiteral(()
parseExpression(()
parsePrecedenceExpression((, 1, true)
parseUnaryExpression((, true)
parsePrimary((, expression)
parseLiteralInt(()
listener: handleLiteralInt(1)
ensureCloseParen(,, ()
listener: endRecordLiteral((, 1, null)
listener: endVariableInitializer(=)
listener: endInitializedIdentifier(record1)
ensureSemicolon())
listener: endVariablesDeclaration(1, ;)
notEofOrValue(}, ()
parseStatement(;)
parseStatementX(;)
parseExpressionStatementOrDeclaration(;, false)
parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, false)
looksLikeLocalFunction(record3)
looksLikeLocalFunction(record2)
listener: beginMetadataStar(()
listener: endMetadataStar(0)
parseRecordType((, ;)
@@ -171,13 +246,13 @@ parseUnit(void)
listener: endRecordTypeNamedFields(1, {)
ensureCloseParen(}, ()
listener: endRecordType((, null, 1, true)
listener: beginVariablesDeclaration(record3, null, null)
listener: beginVariablesDeclaration(record2, null, null)
parseVariablesDeclarationRest(), true)
parseOptionallyInitializedIdentifier())
ensureIdentifier(), localVariableDeclaration)
listener: handleIdentifier(record3, localVariableDeclaration)
listener: beginInitializedIdentifier(record3)
parseVariableInitializerOpt(record3)
listener: handleIdentifier(record2, localVariableDeclaration)
listener: beginInitializedIdentifier(record2)
parseVariableInitializerOpt(record2)
listener: beginVariableInitializer(=)
parseExpression(=)
parsePrecedenceExpression(=, 1, true)
@@ -198,7 +273,7 @@ parseUnit(void)
ensureCloseParen(1, ()
listener: endRecordLiteral((, 1, null)
listener: endVariableInitializer(=)
listener: endInitializedIdentifier(record3)
listener: endInitializedIdentifier(record2)
ensureSemicolon())
listener: endVariablesDeclaration(1, ;)
notEofOrValue(}, ()
@@ -206,53 +281,51 @@ parseUnit(void)
parseStatementX(;)
parseExpressionStatementOrDeclaration(;, false)
parseExpressionStatementOrDeclarationAfterModifiers(;, ;, null, null, null, false)
looksLikeLocalFunction(record4)
looksLikeLocalFunction(record3)
listener: beginMetadataStar(()
listener: endMetadataStar(0)
parseRecordType((, ;)
listener: beginRecordType(()
reportRecoverableError(), EmptyRecordTypeFieldsList)
listener: handleRecoverableError(EmptyRecordTypeFieldsList, ), ))
listener: endRecordType((, null, 0, false)
listener: beginVariablesDeclaration(record4, null, null)
listener: beginVariablesDeclaration(record3, null, null)
parseVariablesDeclarationRest(), true)
parseOptionallyInitializedIdentifier())
ensureIdentifier(), localVariableDeclaration)
listener: handleIdentifier(record4, localVariableDeclaration)
listener: beginInitializedIdentifier(record4)
parseVariableInitializerOpt(record4)
listener: handleIdentifier(record3, localVariableDeclaration)
listener: beginInitializedIdentifier(record3)
parseVariableInitializerOpt(record3)
listener: beginVariableInitializer(=)
parseExpression(=)
parsePrecedenceExpression(=, 1, true)
parseUnaryExpression(=, true)
parsePrimary(=, expression)
parseParenthesizedExpressionFunctionLiteralOrRecordLiteral(=)
parseParenthesizedExpressionOrRecordLiteral(=, null)
listener: beginParenthesizedExpressionOrRecordLiteral(()
parseExpression(()
parsePrecedenceExpression((, 1, true)
parseUnaryExpression((, true)
parsePrimary((, expression)
parseSend((, expression)
isNextIdentifier(()
ensureIdentifier((, expression)
reportRecoverableErrorWithToken(), Instance of 'Template<(Token) => Message>')
listener: handleRecoverableError(Message[ExpectedIdentifier, Expected an identifier, but got ')'., Try inserting an identifier before ')'., {lexeme: )}], ), ))
rewriter()
listener: handleIdentifier(, expression)
listener: handleNoTypeArguments())
parseArgumentsOpt()
listener: handleNoArguments())
listener: handleSend(, ))
ensureCloseParen(, ()
listener: endParenthesizedExpression(()
parseSendOrFunctionLiteral(=, expression)
parseSend(=, expression)
isNextIdentifier(=)
ensureIdentifier(=, expression)
listener: handleIdentifier(Record, expression)
listener: handleNoTypeArguments(.)
parseArgumentsOpt(Record)
listener: handleNoArguments(.)
listener: handleSend(Record, .)
parsePrimary(., expressionContinuation)
parseSendOrFunctionLiteral(., expressionContinuation)
parseSend(., expressionContinuation)
isNextIdentifier(.)
ensureIdentifier(., expressionContinuation)
listener: handleIdentifier(empty, expressionContinuation)
listener: handleNoTypeArguments(;)
parseArgumentsOpt(empty)
listener: handleNoArguments(;)
listener: handleSend(empty, ;)
listener: handleEndingBinaryExpression(.)
listener: endVariableInitializer(=)
listener: endInitializedIdentifier(record4)
ensureSemicolon())
listener: endInitializedIdentifier(record3)
ensureSemicolon(empty)
listener: endVariablesDeclaration(1, ;)
notEofOrValue(}, })
listener: endBlockFunctionBody(4, {, })
listener: endBlockFunctionBody(3, {, })
listener: endTopLevelMethod(void, null, })
listener: endTopLevelDeclaration()
reportAllErrorTokens(void)
listener: endCompilationUnit(1, )
listener: endCompilationUnit(2, )
@@ -1,17 +1,23 @@
NOTICE: Stream was rewritten by parser!
void foo() {
void errors() {
(int, int, { }) record1 = (1, 2);
(int ) record2 = (1);
({int ok}) record3 = (ok: 1);
( ) record4 = (*synthetic*);
(int ) record2 = (1, );
}
void ok() {
(int, ) record1 = (1, );
({int ok}) record2 = (ok: 1);
() record3 = Record.empty;
}
void[KeywordToken] foo[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
void[KeywordToken] errors[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
([BeginToken]int[StringToken],[SimpleToken] int[StringToken],[SimpleToken] {[BeginToken] }[SimpleToken])[SimpleToken] record1[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] 2[StringToken])[SimpleToken];[SimpleToken]
([BeginToken]int[StringToken] )[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken]{[BeginToken]int[StringToken] ok[StringToken]}[SimpleToken])[SimpleToken] record3[StringToken] =[SimpleToken] ([BeginToken]ok[StringToken]:[SimpleToken] 1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken] )[SimpleToken] record4[StringToken] =[SimpleToken] ([BeginToken][SyntheticStringToken])[SimpleToken];[SimpleToken]
([BeginToken]int[StringToken] )[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] )[SimpleToken];[SimpleToken]
}[SimpleToken]
void[KeywordToken] ok[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
([BeginToken]int[StringToken],[SimpleToken] )[SimpleToken] record1[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] )[SimpleToken];[SimpleToken]
([BeginToken]{[BeginToken]int[StringToken] ok[StringToken]}[SimpleToken])[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]ok[StringToken]:[SimpleToken] 1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken])[SimpleToken] record3[StringToken] =[SimpleToken] Record[StringToken].[SimpleToken]empty[StringToken];[SimpleToken]
}[SimpleToken]
[SimpleToken]
@@ -1,15 +1,23 @@
void foo() {
void errors() {
(int, int, { }) record1 = (1, 2);
(int ) record2 = (1);
({int ok}) record3 = (ok: 1);
( ) record4 = ();
(int ) record2 = (1, );
}
void ok() {
(int, ) record1 = (1, );
({int ok}) record2 = (ok: 1);
() record3 = Record.empty;
}
void[KeywordToken] foo[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
void[KeywordToken] errors[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
([BeginToken]int[StringToken],[SimpleToken] int[StringToken],[SimpleToken] {[BeginToken] }[SimpleToken])[SimpleToken] record1[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] 2[StringToken])[SimpleToken];[SimpleToken]
([BeginToken]int[StringToken] )[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken]{[BeginToken]int[StringToken] ok[StringToken]}[SimpleToken])[SimpleToken] record3[StringToken] =[SimpleToken] ([BeginToken]ok[StringToken]:[SimpleToken] 1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken] )[SimpleToken] record4[StringToken] =[SimpleToken] ([BeginToken])[SimpleToken];[SimpleToken]
([BeginToken]int[StringToken] )[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] )[SimpleToken];[SimpleToken]
}[SimpleToken]
void[KeywordToken] ok[StringToken]([BeginToken])[SimpleToken] {[BeginToken]
([BeginToken]int[StringToken],[SimpleToken] )[SimpleToken] record1[StringToken] =[SimpleToken] ([BeginToken]1[StringToken],[SimpleToken] )[SimpleToken];[SimpleToken]
([BeginToken]{[BeginToken]int[StringToken] ok[StringToken]}[SimpleToken])[SimpleToken] record2[StringToken] =[SimpleToken] ([BeginToken]ok[StringToken]:[SimpleToken] 1[StringToken])[SimpleToken];[SimpleToken]
([BeginToken])[SimpleToken] record3[StringToken] =[SimpleToken] Record[StringToken].[SimpleToken]empty[StringToken];[SimpleToken]
}[SimpleToken]
[SimpleToken]
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -71,13 +66,8 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:14:4: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -98,12 +88,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -71,13 +66,8 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:14:4: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -98,12 +88,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -71,13 +66,8 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:14:4: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -98,12 +88,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -71,13 +66,8 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:14:4: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -98,12 +88,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -2,13 +2,8 @@ library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/records/record_type_errors.dart:5:2: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:6:5: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -25,12 +20,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:8:16: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:9:8: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -71,13 +66,8 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:14:4: Error: Record type fields list cannot be empty.
// Try adding a record type field to the list.
// () emptyType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:15:7: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (int) singleType = throw '';
// ^
//
@@ -98,12 +88,12 @@ library /*isNonNullableByDefault*/;
// (var a, {var b}) missingType = throw '';
// ^^^
//
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type fields list cannot contain only one element without a named field.
// Try adding another record type field to the list or add a named field.
// pkg/front_end/testcases/records/record_type_errors.dart:17:18: Error: Record type with one entry requires a trailing comma.
// Try adding a trailing comma.
// (var a, {var b}) missingType = throw '';
// ^
//
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list cannot be empty.
// pkg/front_end/testcases/records/record_type_errors.dart:18:10: Error: Record type named fields list can't be empty.
// Try adding a record type named field to the list.
// (int, {}) emptyNamedFields = throw '';
// ^
@@ -8,7 +8,7 @@ main() {
var r1 = const (42);
// ^
// [analyzer] SYNTACTIC_ERROR.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA
// [cfe] Record literal with one entry requires a trailing comma.
// [cfe] Record literal with one field requires a trailing comma.
var r2 = const ();
// ^
@@ -0,0 +1,17 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// SharedOptions=--enable-experiment=records
main() {
(int, int, {/*missing*/}) r1 = (1, 2);
// ^
// [analyzer] SYNTACTIC_ERROR.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST
// [cfe] Record type named fields list can't be empty.
(int /* missing trailing comma */ ) r2 = (1, );
// ^
// [analyzer] SYNTACTIC_ERROR.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA
// [cfe] Record type with one entry requires a trailing comma.
}
+13
View File
@@ -7,6 +7,7 @@
main() {
(int, int) record1 = (1, 2);
print(record1);
(int x, int y) record1Named = (1, 2);
print(record1Named);
@@ -39,6 +40,18 @@ main() {
List<(int, int)> listOfRecords = [];
var listOfRecords2 = <(int, int)>[];
(int, ) oneElementRecord = (1, );
print(oneElementRecord);
({int ok}) oneElementNamedRecord = (ok: 1);
print(oneElementNamedRecord);
() emptyRecord = Record.empty;
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Undefined name 'Record'.
print(emptyRecord);
}
(int, T) f1<T>(T t) {
@@ -13,7 +13,7 @@ main() {
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^
// [analyzer] SYNTACTIC_ERROR.RECORD_LITERAL_ONE_POSITIONAL_NO_TRAILING_COMMA
// [cfe] Record literal with one entry requires a trailing comma.
// [cfe] Record literal with one field requires a trailing comma.
var r2 = const ();
// ^
@@ -0,0 +1,31 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.9
// SharedOptions=--enable-experiment=records
main() {
(int, int, {/*missing*/}) r1 = (1, 2);
//^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^
// [analyzer] SYNTACTIC_ERROR.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST
// [cfe] Record type named fields list can't be empty.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
(int /* missing trailing comma */ ) r2 = (1, );
//^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^
// [analyzer] SYNTACTIC_ERROR.RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA
// [cfe] Record type with one entry requires a trailing comma.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
}
+27
View File
@@ -116,6 +116,33 @@ main() {
// ^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
(int, ) oneElementRecord = (1, );
//^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
print(oneElementRecord);
({int ok}) oneElementNamedRecord = (ok: 1);
//^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
print(oneElementNamedRecord);
() emptyRecord = Record.empty;
//^
// [analyzer] SYNTACTIC_ERROR.EXPERIMENT_NOT_ENABLED
// [cfe] This requires the experimental 'records' language feature to be enabled.
// ^^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_IDENTIFIER
// [cfe] Undefined name 'Record'.
print(emptyRecord);
}
(int, T) f1<T>(T t) {