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: poor error for constant using missing import #26818

dsymonds opened this Issue Aug 5, 2018 · 1 comment


None yet
4 participants
Copy link

dsymonds commented Aug 5, 2018

Please answer these questions before submitting your issue. Thanks!

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


Does this issue reproduce with the latest release?

I haven't checked, but the playground says it is running Go 1.10.3.

What did you do?

package main

import (

func main() {
	const delay = 5 * time.Second

What did you expect to see?

One error, pointing out that I didn't import "time".

What did you see instead?

Two errors, one of which is misleading:

prog.go:8:8: const initializer 5 * time.Second is not a constant
prog.go:8:20: undefined: time

The first error is outright wrong if the "time" package was imported, yet it was printed, and worse, it came first. The only useful error there is the second message.

@FiloSottile FiloSottile added this to the Go1.12 milestone Aug 6, 2018


This comment has been minimized.

Copy link

odeke-em commented Oct 18, 2018

Thank you for reporting this @dsymonds!

I'll kindly /cc @griesemer too

@odeke-em odeke-em self-assigned this Oct 18, 2018

@griesemer griesemer modified the milestones: Go1.12, Go1.13 Dec 11, 2018

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