What version of Go are you using (go version)?
$ go version
go version go1.15 darwin/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
Wrote code:
package go_closures
func callInt(val int) int {
getInt := func() int { return val }
return callFn(getInt)
}
func callFn(getInt func() int) int {
outer := func() int { return getInt() }
return globalFunc(outer)
}
var globalFunc = func(f func() int) int {
return f()
}
What did you expect to see?
getInt is inlined into outer. outer escapes to the heap.
What did you see instead?
getInt isn't inlined into outer. Both outer and getInt escape to the heap.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes.
What did you do?
Wrote code:
What did you expect to see?
getIntis inlined intoouter.outerescapes to the heap.What did you see instead?
getIntisn't inlined intoouter. BothouterandgetIntescape to the heap.