Skip to content

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

Closed

Description

@mdempsky

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
[...]

Activity

  1. added this to the Go1.11 milestone on Jul 11, 2018
  2. self-assigned this
    on Jul 11, 2018
  3. gopherbot commented on Jul 11, 2018

    @gopherbot
    Contributor

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

  4. locked and limited conversation to collaborators on Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions