Fix silent error in set_mangled_name

This commit is contained in:
Danila Fedorin 2020-09-18 12:02:37 -07:00
parent 77c9b27b26
commit 58c6421681

View File

@ -34,13 +34,14 @@ bool type_env::is_global(const std::string& name) const {
void type_env::set_mangled_name(const std::string& name, const std::string& mangled) { void type_env::set_mangled_name(const std::string& name, const std::string& mangled) {
auto it = names.find(name); auto it = names.find(name);
if(it != names.end()) {
// Can't set mangled name for non-existent variable.
assert(it != names.end());
// Local names shouldn't need mangling. // Local names shouldn't need mangling.
assert(it->second.vis == visibility::global); assert(it->second.vis == visibility::global);
it->second.mangled_name = mangled; it->second.mangled_name = mangled;
} }
}
const std::string& type_env::get_mangled_name(const std::string& name) const { const std::string& type_env::get_mangled_name(const std::string& name) const {
auto it = names.find(name); auto it = names.find(name);