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:
Jon Meow
2021-09-27 11:17:24 -07:00
committed by GitHub
co-authored by Geoff Romer
parent 04ab30f231
commit 5aa958345b
11 changed files with 164 additions and 46 deletions
+4 -6
View File
@@ -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: