mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 16:40:31 +00:00
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:
1 parent
d08805f1a6
commit
b766aa4d16
30 files changed
+1323
-322
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user