Browse Source

Properly handle null types in pattern typechecking.

margin-rework
Danila Fedorin 2 years ago
parent
commit
68910458e8
  1. 5
      code/compiler/12/ast.cpp

5
code/compiler/12/ast.cpp

@ -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());

Loading…
Cancel
Save