mirror of
https://github.com/github/codeql.git
synced 2026-07-30 23:13:01 +02:00
unified: Handle ConditionalPattern in local scoping
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user