Properly handle null types in pattern typechecking.

This commit is contained in:
Danila Fedorin 2020-06-14 00:43:39 -07:00
parent 33f8040886
commit 1e5d43e5e8

View File

@ -355,10 +355,11 @@ void pattern_constr::find_variables(std::set<std::string>& into) const {
}
void pattern_constr::typecheck(type_ptr t, type_mgr& mgr, type_env_ptr& env) const {
type_ptr constructor_type = env->lookup(constr)->instantiate(mgr);
if(!constructor_type) {
type_scheme_ptr constructor_type_scheme = env->lookup(constr);
if(!constructor_type_scheme) {
throw type_error(std::string("pattern using unknown constructor ") + constr);
}
type_ptr constructor_type = constructor_type_scheme->instantiate(mgr);
for(auto& param : params) {
type_arr* arr = dynamic_cast<type_arr*>(constructor_type.get());