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

go/types: types.Named.SetUnderlying: underlying type must not be *Named #15920

Closed
mdempsky opened this issue Jun 1, 2016 · 3 comments
Closed

Comments

@mdempsky
Copy link
Member

mdempsky commented Jun 1, 2016

Run go get github.com/sclasen/swfsm/fsm and then run gotype on this source:

package main

import (
        "fmt"

        "github.com/sclasen/swfsm/fsm"
)

func main() {
        fmt.Println(fsm.StopWalking())
}

Resulting panic:

panic: types.Named.SetUnderlying: underlying type must not be *Named [recovered]
    panic: types.Named.SetUnderlying: underlying type must not be *Named [recovered]
    panic: types.Named.SetUnderlying: underlying type must not be *Named

goroutine 1 [running]:
panic(0x61dd00, 0xc4203e6c40)
    /usr/local/google/home/mdempsky/wd/go/src/runtime/panic.go:500 +0x1a1
main.checkPkgFiles.func2()
    /usr/local/google/home/mdempsky/go/src/golang.org/x/tools/cmd/gotype/gotype.go:211 +0x69
panic(0x61dd00, 0xc4203e6c40)
    /usr/local/google/home/mdempsky/wd/go/src/runtime/panic.go:458 +0x243
go/types.(*Checker).handleBailout(0xc4200ca1c0, 0xc420371d50)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/check.go:213 +0xae
panic(0x61dd00, 0xc4203e6c40)
    /usr/local/google/home/mdempsky/wd/go/src/runtime/panic.go:458 +0x243
go/types.(*Named).SetUnderlying(0xc4203e8b10, 0x779560, 0xc420012960)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/type.go:418 +0x95
go/internal/gcimporter.(*importer).typ(0xc4200c4180, 0x0, 0xc4200c4180, 0x7f4aa4765000)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/bimport.go:287 +0x274
go/internal/gcimporter.(*importer).param(0xc4200c4180, 0x0, 0x1, 0xc420051e98)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/bimport.go:524 +0x49
go/internal/gcimporter.(*importer).paramList(0xc4200c4180, 0x0, 0xc4203e6c00)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/bimport.go:518 +0xb2
go/internal/gcimporter.(*importer).obj(0xc4200c4180, 0xfffffffffffffffb)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/bimport.go:199 +0x38a
go/internal/gcimporter.BImportData(0xc420012c00, 0xc42026a000, 0xb1201, 0xffe00, 0xc42000a681, 0x1c, 0x0, 0x1c, 0xc420013c80, 0xc4200dd540)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/bimport.go:86 +0x34c
go/internal/gcimporter.Import(0xc420012c00, 0xc42000a681, 0x1c, 0x66fa5c, 0x1, 0x0, 0x0, 0x0)
    /usr/local/google/home/mdempsky/wd/go/src/go/internal/gcimporter/gcimporter.go:166 +0x551
go/importer.gcimports.ImportFrom(0xc420012c00, 0xc42000a681, 0x1c, 0x66fa5c, 0x1, 0x0, 0x0, 0x1, 0x0)
    /usr/local/google/home/mdempsky/wd/go/src/go/importer/importer.go:70 +0x67
go/types.(*Checker).collectObjects(0xc4200ca1c0)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc4200ca1c0, 0xc420050070, 0x1, 0x1, 0x0, 0x0)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc4200ca1c0, 0xc420050070, 0x1, 0x1, 0xc420012c60, 0x44e650)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc420010b00, 0x66fd05, 0x3, 0xc420010940, 0xc420050070, 0x1, 0x1, 0x0, 0x401de5, 0xc42000a1f0, ...)
    /usr/local/google/home/mdempsky/wd/go/src/go/types/api.go:344 +0x19f
main.checkPkgFiles(0xc420050070, 0x1, 0x1)
    /usr/local/google/home/mdempsky/go/src/golang.org/x/tools/cmd/gotype/gotype.go:216 +0x1b5
main.main()
    /usr/local/google/home/mdempsky/go/src/golang.org/x/tools/cmd/gotype/gotype.go:251 +0x1d1

Issue originally reported by @dpiddy as mdempsky/gocode#14.

/cc @griesemer

@griesemer griesemer self-assigned this Jun 1, 2016
@griesemer griesemer added this to the Go1.8 milestone Jun 1, 2016
@mdempsky
Copy link
Member Author

mdempsky commented Jun 1, 2016

For what it's worth, this worked with Go 1.6, so this would be a regression in 1.7.

@mdempsky mdempsky modified the milestones: Go1.7Maybe, Go1.8 Jun 1, 2016
@griesemer
Copy link
Contributor

Small repro case.
a.go:

package a
type Error error
func F() Error { return nil }

b.go:

package b
import _ "./a"

Then compile and typecheck:

$ go tool compile a.go && gotype b.go
panic: types.Named.SetUnderlying: underlying type must not be *Named [recovered]
    panic: types.Named.SetUnderlying: underlying type must not be *Named [recovered]
    panic: types.Named.SetUnderlying: underlying type must not be *Named

goroutine 1 [running]:
panic(0x21d480, 0xc4200726f0)
    /Users/gri/go/src/runtime/panic.go:500 +0x1a1
main.checkPkgFiles.func2()
    /Users/gri/go/src/go/types/gotype.go:274 +0x69
panic(0x21d480, 0xc4200726f0)
    /Users/gri/go/src/runtime/panic.go:458 +0x243
go/types.(*Checker).handleBailout(0xc4200d01c0, 0xc420039d70)
    /Users/gri/go/src/go/types/check.go:213 +0xae
panic(0x21d480, 0xc4200726f0)
    /Users/gri/go/src/runtime/panic.go:458 +0x243
go/types.(*Named).SetUnderlying(0xc420076a80, 0x376560, 0xc4200767e0)
    /Users/gri/go/src/go/types/type.go:418 +0x95
go/internal/gcimporter.(*importer).typ(0xc4200ca0c0, 0x0, 0x1a1afa, 0xc4200ca0c0)
    /Users/gri/go/src/go/internal/gcimporter/bimport.go:292 +0x274
go/internal/gcimporter.(*importer).obj(0xc4200ca0c0, 0xfffffffffffffffd)
    /Users/gri/go/src/go/internal/gcimporter/bimport.go:187 +0x74f
go/internal/gcimporter.BImportData(0xc420076960, 0xc4200d5000, 0x5be, 0xe00, 0xc42007269f, 0x1, 0x0, 0x1, 0x8, 0x2)
    /Users/gri/go/src/go/internal/gcimporter/bimport.go:86 +0x34c
go/internal/gcimporter.Import(0xc420076960, 0xc420072638, 0x3, 0x26ec1c, 0x1, 0x0, 0x0, 0x0)
    /Users/gri/go/src/go/internal/gcimporter/gcimporter.go:166 +0x551
go/importer.gcimports.ImportFrom(0xc420076960, 0xc420072638, 0x3, 0x26ec1c, 0x1, 0x0, 0x0, 0x1, 0x0)
    /Users/gri/go/src/go/importer/importer.go:70 +0x67
go/types.(*Checker).collectObjects(0xc4200d01c0)
    /Users/gri/go/src/go/types/resolver.go:191 +0x81d
go/types.(*Checker).checkFiles(0xc4200d01c0, 0xc4200a0048, 0x1, 0x1, 0x0, 0x0)
    /Users/gri/go/src/go/types/check.go:225 +0xaa
go/types.(*Checker).Files(0xc4200d01c0, 0xc4200a0048, 0x1, 0x1, 0xc4200769c0, 0x4e7f0)
    /Users/gri/go/src/go/types/check.go:218 +0x49
go/types.(*Config).Check(0xc4200a4780, 0x26eec5, 0x3, 0xc4200a4680, 0xc4200a0048, 0x1, 0x1, 0x0, 0x2e25, 0xc42000a210, ...)
    /Users/gri/go/src/go/types/api.go:344 +0x19f
main.checkPkgFiles(0xc4200a0048, 0x1, 0x1)
    /Users/gri/go/src/go/types/gotype.go:279 +0x1b5
main.main()
    /Users/gri/go/src/go/types/gotype.go:314 +0x1d1

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/23606 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 1, 2017
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

3 participants