diff --git a/rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll index 0327509c465..80f2259623b 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll @@ -381,7 +381,9 @@ module Impl { class NestedFunctionAccess extends LocalAccess { private Function f; + NestedFunctionAccess() { f = super.getLocal().getDefiningNode() } + /** Gets the function being accessed. */ - Function getFunction() { result = super.getLocal().getDefiningNode() } + Function getFunction() { result = f } } } diff --git a/shared/namebinding/codeql/namebinding/LocalNameBinding.qll b/shared/namebinding/codeql/namebinding/LocalNameBinding.qll index 298f498e331..a467568f983 100644 --- a/shared/namebinding/codeql/namebinding/LocalNameBinding.qll +++ b/shared/namebinding/codeql/namebinding/LocalNameBinding.qll @@ -46,6 +46,10 @@ signature module LocalNameBindingInputSig { * // x is not in scope here * } * ``` + * + * If a local declaration inside the condition is a shadowing sibling declaration + * (see below), then it should use the declaration itself as scope, otherwise it + * should use the condition as scope. */ class Conditional extends AstNode { /** Gets the condition of this conditional. */ @@ -153,8 +157,6 @@ module LocalNameBinding implicitDeclInScope(_, this) or isTopScope(this) - or - lookupStartsAt(_, this) } }