Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix incorrect assertion
  • Loading branch information
tlively committed Apr 15, 2024
commit 022bd4b670d0c86053d0a84d879937536386892c
25 changes: 16 additions & 9 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,23 @@ struct PrintSExpression : public UnifiedExpressionVisitor<PrintSExpression> {
}

TypeNames getNames(HeapType type) {
if (!parent.currModule) {
return fallback.getNames(type);
}
if (auto it = parent.currModule->typeNames.find(type);
it != parent.currModule->typeNames.end()) {
return it->second;
if (parent.currModule) {
if (auto it = parent.currModule->typeNames.find(type);
it != parent.currModule->typeNames.end()) {
return it->second;
}
// In principle we should always have at least a fallback name for every
// type in the module, so this lookup should never fail. In practice,
// though, the `printExpression` variants deliberately avoid walking the
// module to find unnamed types so they can be safely used in a
// function-parallel context. That means we can have a module but not
// have generated the fallback names, so this lookup can fail, in which
// case we generate a name on demand.
if (auto it = fallbackNames.find(type); it != fallbackNames.end()) {
return it->second;
}
}
auto it = fallbackNames.find(type);
assert(it != fallbackNames.end());
return it->second;
return fallback.getNames(type);
}

Name getName(HeapType type) { return getNames(type).name; }
Expand Down