Skip to content

cmd/compile: not inlined closures can't inline inner closures #41988

@DmitriyMV

Description

@DmitriyMV

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.

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions