mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Avoid poisoning non identifier names (#4884)
There are different use cases where we call `Context::LookupQualifiedName()` on non identifiers, like `NameId::SelfType`, which implicitly triggers poisoning these names. I don't think poisoning non identifiers like`Self` is ever useful. Use cases where `Self` is being poisoned: * Checking allowed access: https://github.com/carbon-language/carbon-lang/blob/e257051612e4217295e206fd3274fc75e22d206a/toolchain/check/member_access.cpp#L62, for example, in https://github.com/carbon-language/carbon-lang/blob/e257051612e4217295e206fd3274fc75e22d206a/toolchain/check/testdata/alias/no_prelude/fail_aliased_name_in_diag.carbon#L21 * Using the type `Self` as a parameter type: https://github.com/carbon-language/carbon-lang/blob/e257051612e4217295e206fd3274fc75e22d206a/core/prelude/operators/arithmetic.carbon#L78 Part of #4622.
This commit is contained in:
@@ -66,6 +66,10 @@ auto NameScope::LookupOrAdd(NameId name_id, InstId inst_id,
|
||||
|
||||
auto NameScope::LookupOrPoison(LocId loc_id, NameId name_id)
|
||||
-> std::optional<EntryId> {
|
||||
if (!name_id.AsIdentifierId().has_value()) {
|
||||
return Lookup(name_id);
|
||||
}
|
||||
|
||||
auto insert_result = name_map_.Insert(name_id, EntryId(names_.size()));
|
||||
if (insert_result.is_inserted()) {
|
||||
names_.push_back({.name_id = name_id,
|
||||
|
||||
Reference in New Issue
Block a user