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: constant type mismatch #21074

Closed
OneOfOne opened this issue Jul 18, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@OneOfOne
Copy link
Contributor

commented Jul 18, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Go 1.8.3 / Go git

What operating system and processor architecture are you using (go env)?

Arch Linux 64

What did you do?

blah.go

package main

const ts int64 = 1483228800000000000 / time.Second

blah_test.go

package main
func Test(t *testing.T) {
	t.Logf("%v", ts)
}

What did you expect to see?

./id.go:7:2: cannot use 1483228800000000000 / time.Second (type time.Duration) as type int64 in const initializer

What did you see instead?

./blah.go:7:2: cannot use 1483228800000000000 / time.Second (type time.Duration) as type int64 in const initializer
./blah_test.go:16:39: internal compiler error: constant type mismatch int64(1) int64(0)

goroutine 1 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
        /usr/src/go/src/runtime/debug/stack.go:24 +0xa7
cmd/compile/internal/gc.Fatalf(0xb68f56, 0x24, 0xc4203b2858, 0x4, 0x4)
        /usr/src/go/src/cmd/compile/internal/gc/subr.go:181 +0x230
cmd/compile/internal/gc.evconst(0xc4204eb100)
        /usr/src/go/src/cmd/compile/internal/gc/const.go:941 +0x2a83
cmd/compile/internal/gc.typecheck1(0xc4204eb100, 0x2, 0x0)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:2215 +0x392
cmd/compile/internal/gc.typecheck(0xc4204eb100, 0x2, 0xc42030a200)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:201 +0x764
cmd/compile/internal/gc.typecheckslice(0xc4204ba780, 0x2, 0x2, 0x2)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:55 +0x54
cmd/compile/internal/gc.typecheck1(0xc4204eaf80, 0x12, 0xc4204eae80)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:1262 +0x455f
cmd/compile/internal/gc.typecheck(0xc4204eaf80, 0x12, 0xc4204eae80)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:201 +0x764
cmd/compile/internal/gc.typecheck1(0xc4204eaf00, 0x1, 0xc4204eac80)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:1260 +0x4abb
cmd/compile/internal/gc.typecheck(0xc4204eaf00, 0x1, 0xc4204eac80)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:201 +0x764
cmd/compile/internal/gc.typecheckslice(0xc4204ddaa0, 0x3, 0x4, 0x1)
        /usr/src/go/src/cmd/compile/internal/gc/typecheck.go:55 +0x54
cmd/compile/internal/gc.Main(0xb72f78)
        /usr/src/go/src/cmd/compile/internal/gc/main.go:480 +0x1fd0
main.main()
        /usr/src/go/src/cmd/compile/main.go:49 +0x95

@ianlancetaylor ianlancetaylor changed the title cmd/test: internal compiler error: constant type mismatch cmd/compile: internal compiler error: constant type mismatch Jul 18, 2017

@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Jul 18, 2017

@odeke-em

This comment has been minimized.

Copy link
Member

commented Jul 19, 2017

@OneOfOne I can't seem to reproduce this error on 83fb9c8 i.e Go1.9

$ go version
go version devel +83fb9c8 Tue Jul 18 21:31:15 2017 +0000 darwin/amd64

at least as per https://github.com/odeke-em/bugs/tree/master/golang/21074.

I get back

$ go test -v
# _/Users/emmanuelodeke/Desktop/openSrc/bugs/golang/21074
./blah.go:5:7: cannot use 1483228800000000000 / time.Second (type time.Duration) as type int64 in const initializer
FAIL	_/Users/emmanuelodeke/Desktop/openSrc/bugs/golang/21074 [build failed]

which is the message that you want at least as per your report
screen shot 2017-07-18 at 11 13 19 pm

Perhaps there is more to add to the bug report than has been reported? If so please help with the full repro, otherwise, please try on the Go1.9beta2 or tip, this seems fixed.

@OneOfOne

This comment has been minimized.

Copy link
Contributor Author

commented Jul 19, 2017

That's odd, I can't reproduce it separately :-/
I'll reopen if I can make a better test case.

@OneOfOne OneOfOne closed this Jul 19, 2017

@golang golang locked and limited conversation to collaborators Jul 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.