From f8c2f2cbd9531c2fcac6838ab3899dacccd6bb1c Mon Sep 17 00:00:00 2001 From: Owen Mansel-Chan Date: Wed, 20 May 2026 15:35:34 +0100 Subject: [PATCH] Tweak `getEnclosingCallable` --- go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll index a5c5913faf4..79020e3c897 100644 --- a/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll +++ b/go/ql/lib/semmle/go/controlflow/ControlFlowGraphShared.qll @@ -90,11 +90,12 @@ module GoCfg { Parameter callableGetParameter(Callable c, int index) { none() } Callable getEnclosingCallable(AstNode node) { - result = node and node instanceof Callable + node instanceof Go::FuncDef and result = node or - not node instanceof Callable and result = node.getEnclosingFunction() + not node instanceof Go::FuncDef and + result = node.getEnclosingFunction() or - not node instanceof Callable and + not node instanceof Go::FuncDef and not exists(node.getEnclosingFunction()) and result = node.getFile() }