Skip to content

cmd/compile: internal compiler error: constant type mismatch #21074

@OneOfOne

Description

@OneOfOne

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions