mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:11:04 +01:00
Implement auto return types, removing => returns (#850)
This implements #826, I think covering everything important there. Regarding ReturnTypeContext, I broke that out because it started feeling like a significant number of args to be passing around, and I think this makes the association inside type checking clearer. Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
04ab30f231
commit
5aa958345b
@@ -617,15 +617,13 @@ function_definition:
|
||||
context.SourceLoc(), $2, $3, $4,
|
||||
arena->New<ExpressionPattern>(return_exp), is_omitted_exp, $6);
|
||||
}
|
||||
| FN identifier deduced_params maybe_empty_tuple_pattern DOUBLE_ARROW expression
|
||||
SEMICOLON
|
||||
| FN identifier deduced_params maybe_empty_tuple_pattern ARROW AUTO block
|
||||
{
|
||||
// The return type is not considered "omitted" because it's automatic from
|
||||
// the expression.
|
||||
// The return type is not considered "omitted" because it's `auto`.
|
||||
$$ = arena->New<FunctionDefinition>(
|
||||
context.SourceLoc(), $2, $3, $4,
|
||||
arena->New<AutoPattern>(context.SourceLoc()), true,
|
||||
arena->New<Return>(context.SourceLoc(), $6, true));
|
||||
arena->New<AutoPattern>(context.SourceLoc()),
|
||||
/*is_omitted_exp=*/false, $7);
|
||||
}
|
||||
;
|
||||
function_declaration:
|
||||
|
||||
Reference in New Issue
Block a user