go2pins issueshttps://gitlab.lre.epita.fr/spot/go2pins/-/issues2021-03-02T08:26:37+01:00https://gitlab.lre.epita.fr/spot/go2pins/-/issues/17LinkResults for other packages function2021-03-02T08:26:37+01:00Hugo MoreauLinkResults for other packages functionCalling an external functions with as parameters a function call defined in the current context won't link the proper result(s).
Short example:
```go
package main
import "fmt"
func foo() int {
return 42
}
func main() {
fmt.Pri...Calling an external functions with as parameters a function call defined in the current context won't link the proper result(s).
Short example:
```go
package main
import "fmt"
func foo() int {
return 42
}
func main() {
fmt.Println(foo())
}
```Hugo MoreauHugo Moreauhttps://gitlab.lre.epita.fr/spot/go2pins/-/issues/16Handling multiple assignments to function call2021-03-02T08:00:46+01:00Hugo MoreauHandling multiple assignments to function callWhen it comes to multiple assignments including one that contains a function call, **Go2Pins** fail to handle it well.
Exemple:
```go
package main
func foo() int {
return 42
}
func main() {
a, b := foo(), 2
a, b = 2, foo()
...When it comes to multiple assignments including one that contains a function call, **Go2Pins** fail to handle it well.
Exemple:
```go
package main
func foo() int {
return 42
}
func main() {
a, b := foo(), 2
a, b = 2, foo()
a, b = foo(), foo()
}
```
All of the cases in `main` function does not work. It will ignore everything except the function call.
Thus, an easy way to handle it would be to make one assignment for each function call:
```go
package main
func foo() int {
return 42
}
func main() {
a := foo()
b := 2
a = 2
b = foo()
a = foo()
b = foo()
}
```
We can take a closer look on `transform/cfg/transform.go` and `transform/cfg/linkresults.go` for a proper way to handle it,Hugo MoreauHugo Moreauhttps://gitlab.lre.epita.fr/spot/go2pins/-/issues/15LocalVariableAssignments transform: handling global variables decl before acc...2021-03-03T20:08:03+01:00Hugo MoreauLocalVariableAssignments transform: handling global variables decl before accessing itCurrently `LocalVariablesAssignments` transform does not work well when a **global variables** is declared after accessing it.
Exemple:
```go
package main
func main() {
a = 42
}
var a int
```
Since `meta` hasn't stored it yet in t...Currently `LocalVariablesAssignments` transform does not work well when a **global variables** is declared after accessing it.
Exemple:
```go
package main
func main() {
a = 42
}
var a int
```
Since `meta` hasn't stored it yet in the our vector, no transform will be applied on the `assignment` in the `main` function.
Resulting to something like this:
```go
package main
func G2P_main(G2PState structs.G2PStateType) {
G2PState[5] = 0 // global variable a
a = 42
}
```
Thus, it seems that the "simplest thing" to do is to make a transform before that will handle it.Hugo MoreauHugo Moreauhttps://gitlab.lre.epita.fr/spot/go2pins/-/issues/5Call to empty functions raise errors2020-01-06T15:28:55+01:00Etienne RenaultCall to empty functions raise errorsThe following code
```
package main
func f() {
v1 := 1
v1++
}
func main() {
f()
}
```
raise following errors:
```
panic: runtime error: index out of range
goroutine 1 [running]:
go/ast.(*AssignStmt).Pos(0xc000088ac0, 0...The following code
```
package main
func f() {
v1 := 1
v1++
}
func main() {
f()
}
```
raise following errors:
```
panic: runtime error: index out of range
goroutine 1 [running]:
go/ast.(*AssignStmt).Pos(0xc000088ac0, 0xc0000acd00)
/usr/local/go/src/go/ast/ast.go:723 +0x56
go/printer.(*printer).stmtList(0xc000107a00, 0xc000088bc0, 0x4, 0x4, 0x1, 0x1)
/usr/local/go/src/go/printer/nodes.go:1024 +0x1f7
go/printer.(*printer).block(0xc000107a00, 0xc00008da10, 0x1)
/usr/local/go/src/go/printer/nodes.go:1050 +0xf1
go/printer.(*printer).stmt(0xc000107a00, 0x1368e40, 0xc00008da10, 0x100)
/usr/local/go/src/go/printer/nodes.go:1255 +0x1dae
go/printer.(*printer).stmtList(0xc000107a00, 0xc00008dd10, 0x3, 0x3, 0x1, 0x1)
/usr/local/go/src/go/printer/nodes.go:1027 +0x17f
go/printer.(*printer).block(0xc000107a00, 0xc00008dd40, 0x1)
/usr/local/go/src/go/printer/nodes.go:1050 +0xf1
go/printer.(*printer).stmt(0xc000107a00, 0x1368e40, 0xc00008dd40, 0x100)
/usr/local/go/src/go/printer/nodes.go:1255 +0x1dae
go/printer.(*printer).stmt(0xc000107a00, 0x1369480, 0xc00010b220, 0x100)
/usr/local/go/src/go/printer/nodes.go:1195 +0x817
go/printer.(*printer).stmtList(0xc000107a00, 0xc000088c00, 0x4, 0x4, 0x1, 0x1)
/usr/local/go/src/go/printer/nodes.go:1027 +0x17f
go/printer.(*printer).block(0xc000107a00, 0xc00008df80, 0x1)
/usr/local/go/src/go/printer/nodes.go:1050 +0xf1
go/printer.(*printer).funcBody(0xc000107a00, 0x40000000, 0x4000000b, 0xc00008df80)
/usr/local/go/src/go/printer/nodes.go:1687 +0x47e
go/printer.(*printer).funcDecl(0xc000107a00, 0xc00008dfb0)
/usr/local/go/src/go/printer/nodes.go:1711 +0x189
go/printer.(*printer).decl(0xc000107a00, 0x1369180, 0xc00008dfb0)
/usr/local/go/src/go/printer/nodes.go:1721 +0x157
go/printer.(*printer).declList(0xc000107a00, 0xc0000ae2e0, 0x2, 0x2)
/usr/local/go/src/go/printer/nodes.go:1764 +0x165
go/printer.(*printer).file(0xc000107a00, 0xc0000c8080)
/usr/local/go/src/go/printer/nodes.go:1772 +0x131
go/printer.(*printer).printNode(0xc000107a00, 0x12b5b60, 0xc0000c8080, 0xc0000ac810, 0x0)
/usr/local/go/src/go/printer/printer.go:1152 +0x5f2
go/printer.(*Config).fprint(0x1531a50, 0x1363e80, 0xc000080008, 0xc0000882c0, 0x12b5b60, 0xc0000c8080, 0xc00010c030, 0x10be997, 0xc0000cc0c0)
/usr/local/go/src/go/printer/printer.go:1293 +0x172
go/printer.(*Config).Fprint(...)
/usr/local/go/src/go/printer/printer.go:1351
go/format.Node(0x1363e80, 0xc000080008, 0xc0000882c0, 0x12b5b60, 0xc0000c8080, 0x65, 0x0)
/usr/local/go/src/go/format/format.go:79 +0x114
main.compileTo(0x7ffeefbff943, 0xc, 0xc0000fa000, 0x40, 0x240, 0xc000080008, 0x0, 0xc00008e1a0, 0xd4000000012ed980, 0xc0000b9d01)
/Users/etienne/src/go2pins/main.go:182 +0x4d0
main.main()
/Users/etienne/src/go2pins/main.go:257 +0x332
```