diff --git a/cpg-language-go/src/main/golang/frontend/handler.go b/cpg-language-go/src/main/golang/frontend/handler.go index 8377ab9310..08614cf8f6 100644 --- a/cpg-language-go/src/main/golang/frontend/handler.go +++ b/cpg-language-go/src/main/golang/frontend/handler.go @@ -104,11 +104,6 @@ func (this *GoLanguageFrontend) HandleFile(fset *token.FileSet, file *ast.File, } } - // create a built-in "go" function - goFunc := this.NewFunctionDeclaration(fset, nil, "go", "", true) - goFunc.AddParameter(this.NewParamVariableDeclaration(fset, nil, "call")) - scope.AddDeclaration((*cpg.Declaration)(goFunc)) - // create a new namespace declaration, representing the package p := this.NewNamespaceDeclaration(fset, nil, file.Name.Name) @@ -762,7 +757,7 @@ func (this *GoLanguageFrontend) handleAssignStmt(fset *token.FileSet, assignStmt var rhs = []*cpg.Expression{} var lhs = []*cpg.Expression{} for _, expr := range assignStmt.Lhs { - rhs = append(lhs, this.handleExpr(fset, expr)) + lhs = append(lhs, this.handleExpr(fset, expr)) } for _, expr := range assignStmt.Rhs { diff --git a/cpg-language-go/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoLanguageFrontendTest.kt b/cpg-language-go/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoLanguageFrontendTest.kt index 28711ce406..0be7604b5b 100644 --- a/cpg-language-go/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoLanguageFrontendTest.kt +++ b/cpg-language-go/src/test/kotlin/de/fraunhofer/aisec/cpg/frontends/golang/GoLanguageFrontendTest.kt @@ -464,16 +464,16 @@ class GoLanguageFrontendTest : BaseTest() { val body = myFunc.body as? CompoundStatement assertNotNull(body) - val binOp = body.statements.first() as? BinaryOperator - assertNotNull(binOp) + val assign = body.statements.first() as? AssignExpression + assertNotNull(assign) - val lhs = binOp.lhs as? MemberExpression + val lhs = assign.lhs.firstOrNull() as? MemberExpression assertNotNull(lhs) assertEquals(myFunc.receiver, (lhs.base as? DeclaredReferenceExpression)?.refersTo) assertLocalName("Field", lhs) assertEquals(TypeParser.createFrom("int", GoLanguage()), lhs.type) - val rhs = binOp.rhs as? DeclaredReferenceExpression + val rhs = assign.rhs.firstOrNull() as? DeclaredReferenceExpression assertNotNull(rhs) assertFullName("otherPackage.OtherField", rhs) } @@ -766,8 +766,9 @@ class GoLanguageFrontendTest : BaseTest() { val main = mainPackage.byNameOrNull("main") assertNotNull(main) - val binOp = main.bodyOrNull() - assertNotNull(binOp) + val assign = main.bodyOrNull() + assertNotNull(assign) + assertEquals(1, assign.rhs.size) assertNotNull(tu) }