Repository: go
Issue: cmd/compile: ICE: unexpected types2.Invalid in writePkgStub
Labels: NeedsInvestigation,compiler/runtime,BugReport

Observed in https://ci.chromium.org/ui/p/golang/builders/ci/x_tools-gotip-darwin-amd64-longtest/b8725796120163106641/overview, attached to umbrella issue https://github.com/golang/go/issues/70399#issuecomment-2589049515:

```
=== RUN   TestVetStdlib
    vet_std_test.go:101: go vet std failed (exit status 1):
        # math/rand/v2 [math/rand/v2.test]
        <unknown line number>: internal compiler error: unexpected types2.Invalid
        
        goroutine 1 [running]:
        runtime/debug.Stack()
        	runtime/debug/stack.go:26 +0x5e
        cmd/compile/internal/base.FatalfAt({0x528d00?, 0xc0?}, {0x75726fe, 0x19}, {0x0, 0x0, 0x0})
        	cmd/compile/internal/base/print.go:230 +0x1ea
        cmd/compile/internal/base.Fatalf(...)
        	cmd/compile/internal/base/print.go:195
        cmd/compile/internal/noder.(*pkgWriter).typIdx(0xc000528d00, {0x77dfa70, 0x7d78560}, 0xc000183ea0)
        	cmd/compile/internal/noder/writer.go:533 +0x597
        cmd/compile/internal/noder.(*writer).typ(0xc0007338c0, {0x77dfa70?, 0x7d78560?})
        	cmd/compile/internal/noder/writer.go:481 +0x2f
        cmd/compile/internal/noder.(*writer).unionType(0xc0007338c0, 0xc0000106a8)
        	cmd/compile/internal/noder/writer.go:651 +0x6a
        cmd/compile/internal/noder.(*pkgWriter).typIdx(0xc000528d00, {0x77dfb88, 0xc0000106a8}, 0xc000183ea0)
        	cmd/compile/internal/noder/writer.go:609 +0x42e
        cmd/compile/internal/noder.(*writer).typ(0xc000733810, {0x77dfb88?, 0xc0000106a8?})
        	cmd/compile/internal/noder/writer.go:481 +0x2f
        cmd/compile/internal/noder.(*writer).interfaceType(0xc000733810, 0xc000513310)
        	cmd/compile/internal/noder/writer.go:696 +0x2a5
        cmd/compile/internal/noder.(*pkgWriter).typIdx(0xc000528d00, {0x77dfa20, 0xc000513310}, 0xc000183ea0)
        	cmd/compile/internal/noder/writer.go:605 +0x98a
        cmd/compile/internal/noder.(*writer).typ(0xc000733550, {0x77dfa20?, 0xc000513310?})
        	cmd/compile/internal/noder/writer.go:481 +0x2f
        cmd/compile/internal/noder.(*writer).doObj(0xc000733550, 0xc000733600, {0x77e7760, 0xc0003edbc0})
        	cmd/compile/internal/noder/writer.go:883 +0x318
        cmd/compile/internal/noder.(*pkgWriter).objIdx(0xc000528d00, {0x77e7760, 0xc0003edbc0})
        	cmd/compile/internal/noder/writer.go:815 +0x84b
        cmd/compile/internal/noder.(*pkgWriter).objInstIdx(0xc000528d00, {0x77e7760, 0xc0003edbc0}, 0x0, 0xc000183e00)
        	cmd/compile/internal/noder/writer.go:756 +0xf4
        cmd/compile/internal/noder.(*writer).obj(0xc0007334a0, {0x77e7760?, 0xc0003edbc0?}, 0xc000554380?)
        	cmd/compile/internal/noder/writer.go:730 +0x33
        cmd/compile/internal/noder.(*writer).namedType(0xc0007334a0, 0xc0003edbc0, 0x0)
        	cmd/compile/internal/noder/writer.go:631 +0x52
        cmd/compile/internal/noder.(*pkgWriter).typIdx(0xc000528d00, {0x77df9a8, 0xc000554380}, 0xc000183e00)
        	cmd/compile/internal/noder/writer.go:550 +0x8cc
        cmd/compile/internal/noder.(*writer).typ(0xc000733290, {0x77df9a8?, 0xc000554380?})
        	cmd/compile/internal/noder/writer.go:481 +0x2f
        cmd/compile/internal/noder.(*writer).objDict(0xc000733290, {0x77e7800, 0xc00054e620}, 0xc000183e00)
        	cmd/compile/internal/noder/writer.go:914 +0xea
        cmd/compile/internal/noder.(*pkgWriter).objIdx(0xc000528d00, {0x77e7800, 0xc00054e620})
        	cmd/compile/internal/noder/writer.go:823 +0x8ff
        cmd/compile/internal/noder.(*pkgWriter).objInstIdx(0xc000528d00, {0x77e7800, 0xc00054e620}, 0x0, 0x0)
        	cmd/compile/internal/noder/writer.go:756 +0xf4
        cmd/compile/internal/noder.(*writer).obj(0xc0001a29a0, {0x77e7800?, 0xc00054e620?}, 0x0?)
        	cmd/compile/internal/noder/writer.go:730 +0x33
        cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0xc000431200, 0x7, 0x7})
        	cmd/compile/internal/noder/unified.go:343 +0x6fa
        cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc000431200?, 0x770eaa0?, 0x0?})
        	cmd/compile/internal/noder/unified.go:195 +0xb3
        cmd/compile/internal/noder.LoadPackage({0xc000022460, 0x7, 0x8})
        	cmd/compile/internal/noder/noder.go:77 +0x43a
        cmd/compile/internal/gc.Main(0x77d76e0)
        	cmd/compile/internal/gc/main.go:208 +0xcc5
        main.main()
        	cmd/compile/main.go:57 +0xf9
        
--- FAIL: TestVetStdlib (310.69s)
```