fix: generate closures for literal functions in CFG

This commit is contained in:
Marc Vertes
2019-10-05 19:26:04 +02:00
committed by Traefiker Bot
parent 7d19108f01
commit 4f95c27634
2 changed files with 11 additions and 0 deletions

10
_test/closure8.go Normal file
View File

@@ -0,0 +1,10 @@
package main
var f = func(a int) int { return 2 + a }
func main() {
println(f(3))
}
// Output:
// 5

View File

@@ -871,6 +871,7 @@ func (interp *Interpreter) cfg(root *node) ([]*node, error) {
case funcLit:
n.types = sc.types
sc = sc.pop()
err = genRun(n)
case goStmt:
wireChild(n)