unified: Handle ConditionalPattern in local scoping

This commit is contained in:
Asger F
2026-07-29 13:35:50 +02:00
parent 3923effe64
commit 5ba941e465
2 changed files with 9 additions and 4 deletions

View File

@@ -178,12 +178,12 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
)
or
exists(CatchClause catch |
scope = catch and // ensure both 'body' and 'guard' clause are in scope
scope = catch and // ensure both body and pattern are in scope
pattern = catch.getPattern()
)
or
exists(SwitchCase case |
scope = case and // ensure both 'body' and 'guard' clause are in scope (TODO: merge CatchClause and SwitchCase?)
scope = case and // ensure both body and pattern are in scope
pattern = case.getPattern()
)
or
@@ -207,6 +207,11 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
pattern = pat.getPattern(_)
)
or
exists(ConditionalPattern pat |
bindingContext(pat, scope) and
pattern = pat.getPattern()
)
or
exists(PatternGuardExpr expr |
pattern = expr.getPattern() and
scope = expr

View File

@@ -80,8 +80,8 @@ func t10(value: Int) { // name=value1
// Switch with multiple cases
func t11(value: Int) { // name=value1
switch value { // $ access=value1
case let x where x > 0: // $ MISSING: access=x1 // name=x1
print(x) // $ MISSING: access=x1
case let x where x > 0: // $ access=x1 // name=x1
print(x) // $ access=x1
case let x: // name=x2
print(x) // $ access=x2
}