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

+10
View File
@@ -472,6 +472,16 @@ auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, bool has_error)
}
}
auto Context::AddFunctionTerseDefinitionStart(Lex::TokenIndex token,
bool has_error) -> void {
auto start_id =
AddNode<NodeKind::FunctionTerseDefinitionStart>(token, has_error);
if (ParsingInDeferredDefinitionScope(*this)) {
deferred_definition_stack_.push_back(
tree_->deferred_definitions_.Add({.start_id = start_id}));
}
}
auto Context::AddFunctionDefinition(Lex::TokenIndex token, bool has_error)
-> void {
auto definition_id = AddNode<NodeKind::FunctionDefinition>(token, has_error);