From 9d5f539b57db8f7ef92f25f61076ea49f3288bb4 Mon Sep 17 00:00:00 2001 From: Christian Banse Date: Thu, 21 Nov 2024 10:39:15 +0100 Subject: [PATCH] Fixed Go, Java still broken --- .../kotlin/de/fraunhofer/aisec/cpg/passes/GoExtraPass.kt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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