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

Closed
dsymonds opened this issue Aug 5, 2018 · 2 comments
Closed

cmd/compile: poor error for constant using missing import #26818

dsymonds opened this issue Aug 5, 2018 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dsymonds
Copy link
Contributor

dsymonds commented Aug 5, 2018

Please answer these questions before submitting your issue. Thanks!

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

Playground.

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?

https://play.golang.org/p/KDfoNw1JzXb

package main

import (
	"fmt"
)

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

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 the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 6, 2018
@FiloSottile FiloSottile added this to the Go1.12 milestone Aug 6, 2018
@odeke-em
Copy link
Member

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
@josharian josharian modified the milestones: Go1.13, Go1.14 Jun 3, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@ALTree
Copy link
Member

ALTree commented Jul 22, 2020

This issue has been fixed, the reproducer above now only prints the second error message. Closing here, then.

@ALTree ALTree closed this as completed Jul 22, 2020
@golang golang locked and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants