diff --git a/code/compiler/12/ast.cpp b/code/compiler/12/ast.cpp index df996dc..09fece2 100644 --- a/code/compiler/12/ast.cpp +++ b/code/compiler/12/ast.cpp @@ -355,10 +355,11 @@ void pattern_constr::find_variables(std::set& 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(constructor_type.get());