Skip to content

Commit

Permalink
When adding a namespace, explicitly unpoison an optimistically poison…
Browse files Browse the repository at this point in the history
…ed name (#4826)

Part of #4622
  • Loading branch information
bricknerb authored Jan 21, 2025
1 parent d30957f commit c304e73
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion toolchain/check/import.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ static auto AddNamespace(Context& context, SemIR::TypeId namespace_type_id,
// poisoned optimistically by name lookup before checking for imports, so we
// may be overwriting a poisoned entry here.
auto& entry = parent_scope->GetEntry(entry_id);
if (!inserted && !entry.is_poisoned) {
if (entry.is_poisoned) {
entry.is_poisoned = false;
} else if (!inserted) {
context.DiagnoseDuplicateName(namespace_id, entry.inst_id);
entry.access_kind = SemIR::AccessKind::Public;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fn Run() {
// CHECK:STDOUT: }
// CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
// CHECK:STDOUT: .F = %import_ref.f04
// CHECK:STDOUT: .NS1 = %NS1
// CHECK:STDOUT: import Other//b
// CHECK:STDOUT: import Other//a
// CHECK:STDOUT: }
Expand Down

0 comments on commit c304e73

Please sign in to comment.