From 17c59e595c89a315d4fe515a6e22d259323e5ab3 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 10 Sep 2020 15:05:02 -0700 Subject: [PATCH] Add assertion regarding local name mangling. --- code/compiler/13/ast.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/compiler/13/ast.cpp b/code/compiler/13/ast.cpp index 2ad9d04..24e769a 100644 --- a/code/compiler/13/ast.cpp +++ b/code/compiler/13/ast.cpp @@ -55,9 +55,13 @@ 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); + + // Local names shouldn't need mangling. + assert(!(mangled_name != id && !this->env->is_global(id))); + into.push_back(instruction_ptr( (env->has_variable(mangled_name) && !this->env->is_global(id)) ? - (instruction*) new instruction_push(env->get_offset(mangled_name)) : + (instruction*) new instruction_push(env->get_offset(id)) : (instruction*) new instruction_pushglobal(mangled_name))); }