Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: indexed export format needs inline bodies for map keys #26341

Closed
mdempsky opened this issue Jul 11, 2018 · 1 comment
Closed

cmd/compile: indexed export format needs inline bodies for map keys #26341

mdempsky opened this issue Jul 11, 2018 · 1 comment

Comments

@mdempsky
Copy link
Member

We currently don't export inline bodies for map key types. I thought this was unnecessary since map indexing expressions only yield the map element type, but I forgot that range-based for loops can be used to extract the map key type.

This wasn't a problem for the old binary export format, because if an inline body was unexpectedly missing from the export data, the compiler couldn't distinguish that from it just not being inlineable. But with the indexed export format, we separately track whether a method is inlineable from whether it's (re)exported by any particular package.

$ cat a.go
package a

type k int
func (k) F() {}

type M map[k]int

$ cat b.go
package b

import "./a"

func f() {
        for k := range (a.M{}) {
                k.F()
        }
}

$ go tool compile a.go
$ go tool compile b.go
b.go:7:6: internal compiler error: missing import reader for a.k.F
[...]
@mdempsky mdempsky added this to the Go1.11 milestone Jul 11, 2018
@mdempsky mdempsky self-assigned this Jul 11, 2018
@gopherbot
Copy link

Change https://golang.org/cl/123475 mentions this issue: cmd/compile: fix ICE due to missing inline function body

@golang golang locked and limited conversation to collaborators Jul 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants