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: internal compiler error: unexpected type: <nil> (<nil>) in for-range #67027

Closed
griesemer opened this issue Apr 24, 2024 · 3 comments
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

Reproducer (1.22 and at tip, playground):

package main

func main() {
	var i float64
	for i = range 10 {
		_ = i
	}
}

Running the code leads to:

<unknown line number>: internal compiler error: unexpected type: <nil> (<nil>)

goroutine 1 [running]:
runtime/debug.Stack()
	/usr/local/go/src/runtime/debug/stack.go:26 +0x5e
cmd/compile/internal/base.FatalfAt({0x212300?, 0xc0?}, {0xe130b2, 0x18}, {0xc00008ece0, 0x2, 0x2})
	/usr/local/go/src/cmd/compile/internal/base/print.go:225 +0x1d7
cmd/compile/internal/base.Fatalf(...)
	/usr/local/go/src/cmd/compile/internal/base/print.go:194
cmd/compile/internal/noder.(*pkgWriter).typIdx(0xc000212300, {0x0, 0x0}, 0xc0001aa6e0)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:505 +0x8d9
cmd/compile/internal/noder.(*writer).itab(0xc0004d06e0, {0x0?, 0x0?}, {0xf66fe8, 0x14a7be0})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:2401 +0xa5
cmd/compile/internal/noder.(*writer).convRTTI(0xc0004d06e0, {0x0, 0x0}, {0xf66fe8, 0x14a7be0})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:2415 +0x58
cmd/compile/internal/noder.(*writer).forStmt.func1(0xf66fe8?, {0x0, 0x0})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1475 +0x127
cmd/compile/internal/noder.(*writer).forStmt(0xc0004d06e0, 0xc0004c68c0)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1479 +0x313
cmd/compile/internal/noder.(*writer).stmt1(0xc0004d06e0, {0xf690d0?, 0xc0004c68c0})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1308 +0x25a
cmd/compile/internal/noder.(*writer).stmts(...)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1239
cmd/compile/internal/noder.(*pkgWriter).bodyIdx(0xd79800?, 0xc0004c8580, 0xc0004c8480, 0xc0001aa6e0)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1136 +0x1b3
cmd/compile/internal/noder.(*writer).funcExt(0xc0004d0370, 0xc0004c4700)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:1071 +0x328
cmd/compile/internal/noder.(*writer).doObj(0xc0004d02c0, 0xc0004d0370, {0xf6ef80, 0xc0004c4700})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:828 +0x213
cmd/compile/internal/noder.(*pkgWriter).objIdx(0xc000212300, {0xf6ef80, 0xc0004c4700})
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:787 +0x612
cmd/compile/internal/noder.(*pkgWriter).objInstIdx(0xc000212300, {0xf6ef80, 0xc0004c4700}, 0x0, 0x0)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:728 +0xf0
cmd/compile/internal/noder.(*writer).obj(0xc0004d0000, {0xf6ef80?, 0xc0004c4700?}, 0xc0004c4700?)
	/usr/local/go/src/cmd/compile/internal/noder/writer.go:704 +0x2f
cmd/compile/internal/noder.writePkgStub({0x0?, {0x0?, 0x0?}}, {0xc0001a0598, 0x1, 0x1})
	/usr/local/go/src/cmd/compile/internal/noder/unified.go:325 +0x53e
cmd/compile/internal/noder.unified({0x0?, {0x0?, 0x0?}}, {0xc0001a0598?, 0xd44cc0?, 0x0?})
	/usr/local/go/src/cmd/compile/internal/noder/unified.go:180 +0x9a
cmd/compile/internal/noder.LoadPackage({0xc0001b6100, 0x1, 0x2})
	/usr/local/go/src/cmd/compile/internal/noder/noder.go:77 +0x43a
cmd/compile/internal/gc.Main(0xe3aec0)
	/usr/local/go/src/cmd/compile/internal/gc/main.go:197 +0xbbd
main.main()
	/usr/local/go/src/cmd/compile/main.go:57 +0xf9
@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 24, 2024
@griesemer griesemer added this to the Go1.23 milestone Apr 24, 2024
@griesemer griesemer self-assigned this Apr 24, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Apr 24, 2024
@griesemer
Copy link
Contributor Author

This code should not make it through the type checker.

@gopherbot
Copy link

Change https://go.dev/cl/580937 mentions this issue: go/types, types2: allow range over untyped constants representable as integers

@mknyszek
Copy link
Contributor

mknyszek commented May 8, 2024

In triage, ping @findleyr for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

3 participants