Remove Void (#540)

Implements resolution of #443.
This commit is contained in:
Geoff Romer
2021-06-01 12:48:04 -07:00
committed by GitHub
parent e619d3d632
commit c903eb3133
6 changed files with 69 additions and 5 deletions
@@ -635,7 +635,7 @@ auto TypeCheckFunDef(const FunctionDefinition* f, TypeEnv types, Env values)
// TODO: Check that main doesn't have any parameters.
}
auto res = TypeCheckStmt(f->body, param_res.types, values, return_type);
bool void_return = TypeEqual(return_type, Value::MakeVoidTypeVal());
bool void_return = TypeEqual(return_type, Value::MakeUnitTypeVal());
auto body = CheckOrEnsureReturn(res.stmt, void_return, f->line_num);
return MakeFunDef(f->line_num, f->name, ReifyType(return_type, f->line_num),
f->param_pattern, body);
+1 -1
View File
@@ -272,7 +272,7 @@ auto Value::MakeStructTypeVal(std::string name, VarValues* fields,
return v;
}
auto Value::MakeVoidTypeVal() -> const Value* {
auto Value::MakeUnitTypeVal() -> const Value* {
auto* v = new Value();
v->tag = ValKind::TupleV;
v->u.tuple.elements = new std::vector<TupleElement>();
+1 -1
View File
@@ -149,7 +149,7 @@ struct Value {
static auto MakePtrTypeVal(const Value* type) -> const Value*;
static auto MakeStructTypeVal(std::string name, VarValues* fields,
VarValues* methods) -> const Value*;
static auto MakeVoidTypeVal() -> const Value*;
static auto MakeUnitTypeVal() -> const Value*;
static auto MakeChoiceTypeVal(std::string name, VarValues* alts)
-> const Value*;