diff --git a/code/compiler/12/definition.cpp b/code/compiler/12/definition.cpp index 535a268..551cf03 100644 --- a/code/compiler/12/definition.cpp +++ b/code/compiler/12/definition.cpp @@ -114,15 +114,13 @@ void definition_group::find_free(type_mgr& mgr, type_env_ptr& env, std::setfind_free(mgr, env); - std::set local_dependencies; for(auto& free_var : def_pair.second->free_variables) { if(defs_defn.find(free_var) == defs_defn.end()) { into.insert(free_var); } else { - local_dependencies.insert(free_var); + def_pair.second->nearby_variables.insert(free_var); } } - std::swap(def_pair.second->free_variables, local_dependencies); } } @@ -140,7 +138,7 @@ void definition_group::typecheck(type_mgr& mgr) { def_defn.second->find_free(mgr, env); dependency_graph.add_function(def_defn.second->name); - for(auto& dependency : def_defn.second->free_variables) { + for(auto& dependency : def_defn.second->nearby_variables) { if(defs_defn.find(dependency) == defs_defn.end()) throw 0; dependency_graph.add_edge(def_defn.second->name, dependency); diff --git a/code/compiler/12/definition.hpp b/code/compiler/12/definition.hpp index a063dec..a2309b5 100644 --- a/code/compiler/12/definition.hpp +++ b/code/compiler/12/definition.hpp @@ -30,6 +30,7 @@ struct definition_defn { type_env_ptr env; type_env_ptr var_env; std::set free_variables; + std::set nearby_variables; type_ptr full_type; type_ptr return_type;