Repository navigation
cmd/compile: internal compiler error: got untyped bool for autotmp #17551
Copy link
Copy link
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
Activity
- changed the title
[-]compiler: internal compiler error: got untyped bool for autotmp_7[/-][+]compiler: internal compiler error: got untyped bool for autotmp[/+]on Oct 22, 2016 - changed the title
[-]compiler: internal compiler error: got untyped bool for autotmp[/-][+]cmd/compile: internal compiler error: got untyped bool for autotmp[/+]on Oct 22, 2016 This appears to be a side-effect of 6286188.
Thanks for the concise test case. In my (somewhat long) queue.
@josharian I had to extract it from the code I've been working on. Glad to be able to help :)
Interestingly the bug only manifests with a named return signature
ie this works alright the difference being:6c6 < func Y() (int, bool) { --- > func Y() (i int, ok bool) {
Passes
package main func main() { _, y := Y() if y {} } func Y() (int, bool) { ii := int(1) return ii, 0 <= ii && ii < 20 }
Fails
package main func main() { _, _ = Y() } func Y() (i int, ok bool) { ii := int(1) return ii, 0 <= ii && ii < 20 }
./fails.go:8: internal compiler error: got untyped bool for autotmp_2 goroutine 1 [running]: runtime/debug.Stack(0x0, 0x0, 0x0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/runtime/debug/stack.go:24 +0x79 cmd/compile/internal/gc.Fatalf(0x644b18, 0xd, 0xc42031d540, 0x2, 0x2) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/subr.go:165 +0x226 cmd/compile/internal/gc.typecheckdef(0xc4203655f0, 0xc42031d640) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:3782 +0x488 cmd/compile/internal/gc.typecheck1(0xc4203655f0, 0x22, 0xc420356520) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:266 +0xca51 cmd/compile/internal/gc.typecheck(0xc4203655f0, 0x22, 0x4e7e9f) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x602 cmd/compile/internal/gc.typecheckas(0xc420365680) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:3253 +0x78 cmd/compile/internal/gc.typecheck1(0xc420365680, 0x1, 0x690bf4) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:1963 +0x37ce cmd/compile/internal/gc.typecheck(0xc420365680, 0x1, 0xc4203654d0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/typecheck.go:188 +0x602 cmd/compile/internal/gc.copyexpr(0xc4203654d0, 0xc4200189c0, 0xc4203566d0, 0x10) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/subr.go:1336 +0x68 cmd/compile/internal/gc.cheapexpr(0xc4203654d0, 0xc4203566d0, 0x10) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/subr.go:1350 +0x5d cmd/compile/internal/gc.safeexpr(0xc4203654d0, 0xc4203566d0, 0xc420349dd0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/subr.go:1330 +0x1fd cmd/compile/internal/gc.walkexprlistsafe(0xc420012c80, 0x2, 0x2, 0xc4203566d0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/walk.go:401 +0x56 cmd/compile/internal/gc.walkstmt(0xc4203566c0, 0xc4203565a0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/walk.go:337 +0x478 cmd/compile/internal/gc.walkstmtlist(0xc420335600, 0x5, 0x8) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/walk.go:80 +0x44 cmd/compile/internal/gc.walk(0xc4203498c0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/walk.go:65 +0x1c0 cmd/compile/internal/gc.compile(0xc4203498c0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/pgen.go:347 +0x1c5 cmd/compile/internal/gc.funccompile(0xc4203498c0) /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/dcl.go:1303 +0xdc cmd/compile/internal/gc.Main() /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/internal/gc/main.go:476 +0x1f50 main.main() /Users/emmanuelodeke/go/src/go.googlesource.com/go/src/cmd/compile/main.go:47 +0x15d
@odeke-em yeah, I mentioned it in the issue. Error does not occur when there is single named bool returned.
Also, these combinations will work:
return 0 <= 1 && ii <= 0x7fffffff, iireturn 0 <= ii && 1 <= 0x7fffffff, iireturn 0 <= 1 && 0 <= 0x7fffffff, ii
So probably as @0xmohit mentioned it's a side effect of optimization introduced in 6286188
- addedNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
on Oct 24, 2016 CL https://golang.org/cl/31857 mentions this issue.
- locked and limited conversation to collaborators
on Oct 24, 2017
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go version devel +eb15cf1 Sat Oct 22 01:23:14 2016 +0000 darwin/amd64What operating system and processor architecture are you using (
go env)?What did you do?
This is minimal example I've been able to create to reproduce this error (works in go 1.7.3):
What did you expect to see?
What did you see instead?
Works with:
return ii, bool(0 <= ii && ii <= 0x7fffffff)func X() (int, bool)