diff --git a/code/compiler/12/ast.cpp b/code/compiler/12/ast.cpp index 602d7fb..df996dc 100644 --- a/code/compiler/12/ast.cpp +++ b/code/compiler/12/ast.cpp @@ -50,10 +50,11 @@ void ast_lid::translate(global_scope& scope) { } void ast_lid::compile(const env_ptr& env, std::vector& into) const { + auto mangled_name = this->env->get_mangled_name(id); into.push_back(instruction_ptr( - (env->has_variable(id) && !this->env->is_global(id)) ? - (instruction*) new instruction_push(env->get_offset(id)) : - (instruction*) new instruction_pushglobal(this->env->get_mangled_name(id)))); + (env->has_variable(mangled_name) && !this->env->is_global(id)) ? + (instruction*) new instruction_push(env->get_offset(mangled_name)) : + (instruction*) new instruction_pushglobal(mangled_name))); } void ast_uid::print(int indent, std::ostream& to) const { @@ -238,7 +239,7 @@ void ast_case::compile(const env_ptr& env, std::vector& into) c } else if((cpat = dynamic_cast(branch->pat.get()))) { env_ptr new_env = env; for(auto it = cpat->params.rbegin(); it != cpat->params.rend(); it++) { - new_env = env_ptr(new env_var(*it, new_env)); + new_env = env_ptr(new env_var(branch->expr->env->get_mangled_name(*it), new_env)); } branch_instructions.push_back(instruction_ptr(new instruction_split( @@ -319,7 +320,7 @@ void ast_let::compile(const env_ptr& env, std::vector& into) co into.push_back(instruction_ptr(new instruction_alloc(translated_definitions.size()))); env_ptr new_env = env; for(auto& def : translated_definitions) { - new_env = env_ptr(new env_var(def.first, std::move(new_env))); + new_env = env_ptr(new env_var(definitions.env->get_mangled_name(def.first), std::move(new_env))); } int offset = translated_definitions.size() - 1; for(auto& def : translated_definitions) {