Detect impl redecls in non-declarative scopes (#7170)

Avoid crashing on the fact that block scopes have no related InstId. So
we can't push the InstId of the current scope in the ImplIntroducer
node, as it can be None. Instead we have to find the parent InstId when
we're building the ImplDecl, because the ImplDecl has a node at the top
of the scope stack for the DeclNameStack.

Impls are allowed in sequential (non-declarative) scopes (functions,
blocks), but [redeclarations are not
allowed](https://github.com/carbon-language/carbon-lang/blob/db24042fe56d22275aa801696e2f8f5c4171e35b/proposals/p3763.md?plain=1#L279).
We now diagnose these redecls as invalid.
This commit is contained in:
Dana Jansens
2026-05-07 13:44:40 +00:00
committed by GitHub
parent daebbf32fa
commit 6776e2b804
9 changed files with 266 additions and 417 deletions
+1
View File
@@ -7,6 +7,7 @@
#include <utility>
#include "common/check.h"
#include "common/find.h"
#include "toolchain/check/context.h"
#include "toolchain/check/unused.h"
#include "toolchain/sem_ir/ids.h"