From 58c6421681d5bf6e54822b10508c9609db84a2c6 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 18 Sep 2020 12:02:37 -0700 Subject: [PATCH] Fix silent error in set_mangled_name --- 13/type_env.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/13/type_env.cpp b/13/type_env.cpp index 6f4fe6a..0c0ddef 100644 --- a/13/type_env.cpp +++ b/13/type_env.cpp @@ -34,12 +34,13 @@ bool type_env::is_global(const std::string& name) const { void type_env::set_mangled_name(const std::string& name, const std::string& mangled) { auto it = names.find(name); - if(it != names.end()) { - // Local names shouldn't need mangling. - assert(it->second.vis == visibility::global); - it->second.mangled_name = mangled; - } + // Can't set mangled name for non-existent variable. + assert(it != names.end()); + // Local names shouldn't need mangling. + assert(it->second.vis == visibility::global); + + it->second.mangled_name = mangled; } const std::string& type_env::get_mangled_name(const std::string& name) const {