Add assertion regarding local name mangling.

This commit is contained in:
Danila Fedorin 2020-09-10 15:05:02 -07:00
parent ad2576eae2
commit 17c59e595c

View File

@ -55,9 +55,13 @@ void ast_lid::translate(global_scope& scope) {
void ast_lid::compile(const env_ptr& env, std::vector<instruction_ptr>& 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)));
}