mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-25 11:50:13 +01:00
Factor out AST node for function return types. (#912)
This enables us to stop treating the return type as a Pattern (which is really isn't), treat return types more consistently with other static types in the typechecker, and drop ReturnTypeContext. Additional changes: - Merge TypeCheckFunDef with TypeOfFunDef. - Handle implicit conversions in `return` statements. - Require function type literals to have an explicit `->`. - Move consistency check for omitted returns from TypeChecker to ResolveControlFlow.
This commit is contained in:
@@ -32,8 +32,7 @@ static void AddIntrinsics(Nonnull<Arena*> arena,
|
||||
auto print = arena->New<FunctionDeclaration>(
|
||||
source_loc, "Print", std::vector<Nonnull<GenericBinding*>>(),
|
||||
arena->New<TuplePattern>(source_loc, print_params),
|
||||
arena->New<ExpressionPattern>(arena->New<TupleLiteral>(source_loc)),
|
||||
/*is_omitted_return_type=*/false, print_return);
|
||||
ReturnTerm::Explicit(arena->New<TupleLiteral>(source_loc)), print_return);
|
||||
declarations->insert(declarations->begin(), print);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user