Skip to content

Commit

Permalink
fix: generate closures for literal functions in CFG
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertes authored and traefiker committed Oct 5, 2019
1 parent 7d19108 commit 4f95c27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions _test/closure8.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

var f = func(a int) int { return 2 + a }

func main() {
println(f(3))
}

// Output:
// 5
1 change: 1 addition & 0 deletions interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4f95c27

Please sign in to comment.