Skip to content

cmd/compile: internal compiler error: got nil for t (1.7.5, 1.8.1 and tip) #20185

Closed

Description

@ALTree

The following program:

package p

func F() {
	switch t := nil.(type) {
	default:
		_ = t
	}
}

crashes the go1.7.5, go1.8.1 and tip compilers with the following error:

# command-line-arguments
./prova.go:4: cannot type switch on non-interface value nil
./prova.go:4: internal compiler error: got nil for t

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x79
cmd/compile/internal/gc.Fatalf(0xaba22d, 0xd, 0xc420309a18, 0x2, 0x2)
	/usr/local/go/src/cmd/compile/internal/gc/subr.go:167 +0x226
cmd/compile/internal/gc.typecheckdef(0xc420338f30, 0xc42001f560)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:3781 +0x41a
cmd/compile/internal/gc.typecheck1(0xc420338f30, 0x22, 0x90)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:266 +0xdd5b
cmd/compile/internal/gc.typecheck(0xc420338f30, 0x22, 0xc42030aab0)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x608
cmd/compile/internal/gc.typecheckswitch(0xc420338c60)
	/usr/local/go/src/cmd/compile/internal/gc/swt.go:185 +0x2b8
cmd/compile/internal/gc.typecheck1(0xc420338c60, 0x1, 0x4)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:2068 +0xc7a8
cmd/compile/internal/gc.typecheck(0xc420338c60, 0x1, 0x3)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x608
cmd/compile/internal/gc.typecheckslice(0xc42000c588, 0x1, 0x1, 0x1)
	/usr/local/go/src/cmd/compile/internal/gc/typecheck.go:49 +0x4e
cmd/compile/internal/gc.Main()
	/usr/local/go/src/cmd/compile/internal/gc/main.go:374 +0x1938
main.main()
	/usr/local/go/src/cmd/compile/main.go:50 +0xfe

Activity

  1. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Apr 30, 2017
  2. added this to the Go1.9 milestone on Apr 30, 2017
  3. bradfitz commented on Apr 30, 2017

    @bradfitz
    Contributor
  4. tzneal commented on Apr 30, 2017

    @tzneal
    Member

    It happens with type switching on anything untyped:

    const x = 1
    
    func G() {
    	switch t := x.(type) {
    	default:
    	}
    }
    

    Testing a fix now.

  5. josharian commented on Apr 30, 2017

    @josharian
    Contributor

    @tzneal awesome. There's an outside chance that your fix might also address #19977 -- worth checking, anyway.

  6. ALTree commented on Apr 30, 2017

    @ALTree
    MemberAuthor

    If it doesn't, I have a patch for #19977 (in fact, I found this bug while working on that one).

  7. gopherbot commented on Apr 30, 2017

    @gopherbot
    Contributor

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

  8. locked and limited conversation to collaborators on Apr 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions