mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 06:15:52 +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:
@@ -944,11 +944,11 @@ auto Interpreter::StepStmt() -> Transition {
|
||||
} else {
|
||||
// { {v :: return [] :: C, E, F} :: {C', E', F'} :: S, H}
|
||||
// -> { {v :: C', E', F'} :: S, H}
|
||||
// TODO(geoffromer): convert the result to the function's return type,
|
||||
// once #880 gives us a way to find that type.
|
||||
const FunctionDeclaration& function = cast<Return>(stmt).function();
|
||||
return UnwindPast{.ast_node = *function.body(),
|
||||
.result = act.results()[0]};
|
||||
return UnwindPast{
|
||||
.ast_node = *function.body(),
|
||||
.result = Convert(act.results()[0],
|
||||
&function.return_term().static_type())};
|
||||
}
|
||||
case Statement::Kind::Continuation: {
|
||||
CHECK(act.pos() == 0);
|
||||
|
||||
Reference in New Issue
Block a user