From 68910458e8da917f9905760f403ece716f0e7d97 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Sun, 14 Jun 2020 00:43:39 -0700 Subject: [PATCH] Properly handle null types in pattern typechecking. --- code/compiler/12/ast.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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());