mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-03 14:56:10 +01:00
Convert Statement to use Ptr (#788)
Note this makes a few cases where the Statement was optional explicit (Block, If, Sequence). I do add a few CHECKs around where statements were optional and assumed but unverified. I switch TypeCheckStmt to not take an optional Statement because I think it makes the call sites clearer in behavior. It's also a smaller change than the converse, because taking an optional Statement means the returned statement would also need to be optional. Arguably a wrapper for optional statements could be added, but this still seems cleaner to me, and there aren't that many cases of an optional statement. Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
ed2d171703
commit
36ed79dc25
@@ -26,7 +26,8 @@ struct FunctionDefinition {
|
||||
std::vector<GenericBinding> deduced_params,
|
||||
Ptr<const TuplePattern> param_pattern,
|
||||
Ptr<const Pattern> return_type,
|
||||
bool is_omitted_return_type, const Statement* body)
|
||||
bool is_omitted_return_type,
|
||||
std::optional<Ptr<const Statement>> body)
|
||||
: source_location(source_location),
|
||||
name(std::move(name)),
|
||||
deduced_parameters(deduced_params),
|
||||
@@ -45,7 +46,7 @@ struct FunctionDefinition {
|
||||
Ptr<const TuplePattern> param_pattern;
|
||||
Ptr<const Pattern> return_type;
|
||||
bool is_omitted_return_type;
|
||||
const Statement* body;
|
||||
std::optional<Ptr<const Statement>> body;
|
||||
};
|
||||
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user