Update AstBuilder to handle named function declaration

Change-Id: I34e699e49b7138b6d0ecf7087afef9739888c716
Reviewed-on: https://dart-review.googlesource.com/49240
Commit-Queue: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
Dan Rubel 2018-04-03 20:45:19 +00:00 committed by commit-bot@chromium.org
parent ddbe2eece1
commit 701e02b2fa
4 changed files with 26 additions and 39 deletions

View file

@ -2102,17 +2102,22 @@ class AstBuilder extends ScopeListener {
@override
void endNamedFunctionExpression(Token endToken) {
// TODO(scheglov): The logEvent() invocation is commented because it
// spams to the console. We already know that these test fail, uncomment
// when you are working on fixing them.
// logEvent("NamedFunctionExpression");
unhandled("NamedFunctionExpression", "$runtimeType", -1, uri);
debugEvent("NamedFunctionExpression");
FunctionBody body = pop();
if (isFullAst) {
pop(); // constructor initializers
pop(); // separator before constructor initializers
}
FormalParameterList parameters = pop();
pop(); // name
pop(); // returnType
TypeParameterList typeParameters = pop();
push(ast.functionExpression(typeParameters, parameters, body));
}
@override
void endLocalFunctionDeclaration(Token token) {
debugEvent("LocalFunctionDeclaration");
FunctionBody body = pop();
if (isFullAst) {
pop(); // constructor initializers

View file

@ -506,27 +506,6 @@ class ErrorParserTest_Fasta extends FastaParserTestCase
super.test_mixin_application_lacks_with_clause();
}
@override
@failingTest
void test_namedFunctionExpression() {
// TODO(brianwilkerson) Does not recover.
// Internal problem: Compiler cannot run without a compiler context.
// Tip: Are calls to the compiler wrapped in CompilerContext.runInContext?
// package:front_end/src/fasta/compiler_context.dart 81:7 CompilerContext.current
// package:front_end/src/fasta/problems.dart 29:25 internalProblem
// package:front_end/src/fasta/problems.dart 41:10 unhandled
// package:front_end/src/fasta/source/stack_listener.dart 126:5 StackListener.logEvent
// package:analyzer/src/fasta/ast_builder.dart 1548:5 AstBuilder.endNamedFunctionExpression
// test/generated/parser_fasta_listener.dart 938:14 ForwardingTestListener.endNamedFunctionExpression
// package:front_end/src/fasta/parser/parser.dart 2520:16 Parser.parseNamedFunctionRest
// package:front_end/src/fasta/parser/parser.dart 1379:16 Parser.parseType
// package:front_end/src/fasta/parser/parser.dart 3365:14 Parser.parseSendOrFunctionLiteral
// package:front_end/src/fasta/parser/parser.dart 3127:14 Parser.parsePrimary
// test/generated/parser_fasta_test.dart 3320:31 FastaParserTestCase.parsePrimaryExpression.<fn>.<fn>
// test/generated/parser_fasta_test.dart 3702:39 ParserProxy._run
super.test_namedFunctionExpression();
}
@override
@failingTest
void test_nonConstructorFactory_field() {

View file

@ -4849,13 +4849,22 @@ class Wrong<T> {
errors: [expectedError(ParserErrorCode.MULTIPLE_WITH_CLAUSES, 25, 4)]);
}
@failingTest
void test_namedFunctionExpression() {
Expression expression = parsePrimaryExpression('f() {}');
expectNotNullIfNoErrors(expression);
listener.assertErrors(
[expectedError(ParserErrorCode.NAMED_FUNCTION_EXPRESSION, 0, 1)]);
expect(expression, new isInstanceOf<FunctionExpression>());
Expression expression;
if (usingFastaParser) {
createParser('f() {}');
expression = parser.parsePrimaryExpression();
listener.assertErrors(
[expectedError(ParserErrorCode.NAMED_FUNCTION_EXPRESSION, 0, 1)]);
expect(expression, new isInstanceOf<FunctionExpression>());
} else {
expression = parsePrimaryExpression('f() {}');
expectNotNullIfNoErrors(expression);
// Should generate an error.
//listener.assertErrors(
// [expectedError(ParserErrorCode.NAMED_FUNCTION_EXPRESSION, 0, 1)]);
//expect(expression, new isInstanceOf<FunctionExpression>());
}
}
void test_namedParameterOutsideGroup() {

View file

@ -8,8 +8,6 @@ annotation_top: Crash
argument_mismatch: Fail
bug32629: Fail
dynamic_and_void: Fail
illegal_named_function_expression: Crash
illegal_named_function_expression_scope: Crash
inference/abstract_class_instantiation: Fail
inference/constructors_too_many_positional_arguments: Fail
inference/downwards_inference_annotations: Crash
@ -51,12 +49,8 @@ rasta/issue_000039: VerificationError
rasta/mandatory_parameter_initializer: VerificationError
rasta/parser_error: VerificationError
rasta/unresolved_for_in: Crash
regress/issue_29937: Crash
regress/issue_29941: Crash
regress/issue_29942: Crash
regress/issue_29943: Crash
regress/issue_29978: Crash
regress/issue_29979: Crash
regress/issue_29983: Crash # 'package:analyzer/src/fasta/ast_builder.dart': Failed assertion: line 478 pos 12: 'star == null': is not true.
regress/issue_31155: Crash # Issue 31155.
regress/issue_31157: Crash