Basic checking for match_first blocks (#7481)

Push a scope_stack entry for match_first blocks, and handle impls being
inside those scope entries. An impl should not use the `match_first`
block as its "enclosing scope" for the purpose of deciding if the impl
is a redecl of another impl. We should look through it to the class or
namespace the impl (and match_first) are located inside.

We don't yet store the relationship between the impl and its match_first
block, nor then can we use it in impl lookup for prioritization.
This commit is contained in:
Dana Jansens
2026-07-11 14:01:38 +00:00
committed by GitHub
parent 8be274cf60
commit a46f4863db
7 changed files with 155 additions and 6 deletions
+5
View File
@@ -128,6 +128,11 @@ auto ScopeStack::PushForFunctionBody(SemIR::InstId scope_inst_id) -> void {
destroy_id_stack_.PushArray();
}
auto ScopeStack::PushForMatchFirstBlock(SemIR::InstId scope_inst_id) -> void {
Push(scope_inst_id, SemIR::NameScopeId::None, SemIR::SpecificId::None,
/*lexical_lookup_has_load_error=*/false);
}
auto ScopeStack::Pop(bool check_unused) -> void {
auto scope = scope_stack_.pop_back_val();