mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Clarify what specific name in the Core package is looked for when diagnosing that the Core package is not found (#4571)
I believe this makes the error easier to understand.
This commit is contained in:
@@ -608,7 +608,7 @@ auto Context::LookupQualifiedName(SemIRLoc loc, SemIR::NameId name_id,
|
||||
//
|
||||
// TODO: Consider tracking the Core package in SemIR so we don't need to use
|
||||
// name lookup to find it.
|
||||
static auto GetCorePackage(Context& context, SemIRLoc loc)
|
||||
static auto GetCorePackage(Context& context, SemIRLoc loc, llvm::StringRef name)
|
||||
-> SemIR::NameScopeId {
|
||||
auto core_ident_id = context.identifiers().Add("Core");
|
||||
auto packaging = context.parse_tree().packaging_decl();
|
||||
@@ -630,15 +630,17 @@ static auto GetCorePackage(Context& context, SemIRLoc loc)
|
||||
}
|
||||
}
|
||||
|
||||
CARBON_DIAGNOSTIC(CoreNotFound, Error,
|
||||
"package `Core` implicitly referenced here, but not found");
|
||||
context.emitter().Emit(loc, CoreNotFound);
|
||||
CARBON_DIAGNOSTIC(
|
||||
CoreNotFound, Error,
|
||||
"`Core.{0}` implicitly referenced here, but package `Core` not found",
|
||||
std::string);
|
||||
context.emitter().Emit(loc, CoreNotFound, name.str());
|
||||
return SemIR::NameScopeId::Invalid;
|
||||
}
|
||||
|
||||
auto Context::LookupNameInCore(SemIRLoc loc, llvm::StringRef name)
|
||||
-> SemIR::InstId {
|
||||
auto core_package_id = GetCorePackage(*this, loc);
|
||||
auto core_package_id = GetCorePackage(*this, loc, name);
|
||||
if (!core_package_id.is_valid()) {
|
||||
return SemIR::InstId::BuiltinErrorInst;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user