Start attempting ambiguous import merges. (#3827)

Just connecting this together. Note the diagnostics still need to be
cleaned up/improved, although this is correctly handling some cases.

This exposed an incorrect parameter passed in DiagnosticEmitter, which
is fixed here -- context_fn shouldn't include args. Note this was caught
by the CHECK, I'm just expanding on the message since I used the detail
to help figure out the bug.
This commit is contained in:
Jon Ross-Perkins
2024-04-02 11:21:47 +00:00
committed by GitHub
parent e66406ec93
commit da86a1bbb9
4 changed files with 21 additions and 40 deletions
+3 -3
View File
@@ -14,6 +14,7 @@
#include "toolchain/check/eval.h"
#include "toolchain/check/import_ref.h"
#include "toolchain/check/inst_block_stack.h"
#include "toolchain/check/merge.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/parse/node_ids.h"
@@ -337,11 +338,10 @@ static auto LookupInImportIRScopes(Context& context, SemIRLoc loc,
continue;
}
auto import_inst_id = context.AddImportRef(import_ir_id, it->second);
TryResolveImportRefUnused(context, import_inst_id);
if (result_id.is_valid()) {
// TODO: Add generalized merge functionality (merge_decls.h?).
context.DiagnoseDuplicateName(import_inst_id, result_id);
MergeImportRef(context, import_inst_id, result_id);
} else {
TryResolveImportRefUnused(context, import_inst_id);
result_id = import_inst_id;
}
}