mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 22:02:33 +01:00
Add support for return; (#678)
This creates a ReturnExpression. A separate change should enforce that an implicit return of `()` is only allowed in functions that have an implicit return type of `()`, and I think the structure taken here should ease that.
This commit is contained in:
@@ -100,12 +100,17 @@ auto Expression::MakeContinuationTypeLiteral(int line_num)
|
||||
return type;
|
||||
}
|
||||
|
||||
auto Expression::MakeFunctionTypeLiteral(int line_num, const Expression* param,
|
||||
const Expression* ret)
|
||||
auto Expression::MakeFunctionTypeLiteral(int line_num,
|
||||
const Expression* parameter,
|
||||
const Expression* return_type,
|
||||
bool is_omitted_return_type)
|
||||
-> const Expression* {
|
||||
auto* t = global_arena->New<Expression>();
|
||||
t->line_num = line_num;
|
||||
t->value = FunctionTypeLiteral({.parameter = param, .return_type = ret});
|
||||
t->value =
|
||||
FunctionTypeLiteral({.parameter = parameter,
|
||||
.return_type = return_type,
|
||||
.is_omitted_return_type = is_omitted_return_type});
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user