diff --git a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt index 77e3cc32ac..b4750f981f 100644 --- a/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt +++ b/cpg-language-go/src/main/kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt @@ -348,9 +348,12 @@ class GoExtraPass(ctx: TranslationContext) : ComponentPass(ctx) { // Loop through the target variables (left-hand side) for ((idx, expr) in assign.lhs.withIndex()) { if (expr is Reference) { - // And try to resolve it - val ref = scopeManager.resolveReference(expr) - if (ref == null) { + // And try to resolve it as a variable + val ref = + scopeManager.lookupSymbolByName(expr.name, expr.location, expr.scope) { + it is VariableDeclaration + } + if (ref.isEmpty()) { // We need to implicitly declare it, if it's not declared before. val decl = newVariableDeclaration(expr.name, expr.autoType()) decl.language = expr.language