Support for terse => function bodies (#7895)

Treat the function as having a `-> auto` return type. Reject calls to
functions that still have a non-deduced `-> auto` return type, and
rewrite the function to have the actual return type once it is known.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith authored and GitHub committed 2026-10-16 21:48:48 +00:00
1 parent d08805f1a6
commit b766aa4d16
30 files changed
+1323 -322

No files matched your search

+4 -1
View File
@@ -74,7 +74,10 @@ auto HandleFunctionSignatureFinish(Context& context) -> void {
break;
}
case Lex::TokenKind::EqualGreater: {
context.AddFunctionDefinitionStart(context.Consume(), state.has_error);
context.AddFunctionTerseDefinitionStart(context.Consume(),
state.has_error);
// Any error is recorded on the FunctionTerseDefinitionStart.
state.has_error = false;
context.PushState(state, StateKind::FunctionTerseBodyFinish);
context.PushStateForExpr(PrecedenceGroup::ForTopLevelExpr());
break;