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: confusing type checking error #14948

aclements opened this issue Mar 24, 2016 · 2 comments

cmd/compile: confusing type checking error #14948

aclements opened this issue Mar 24, 2016 · 2 comments


Copy link

@aclements aclements commented Mar 24, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    go version go1.6 linux/amd64
  2. What operating system and processor architecture are you using (go env)?
  3. What did you do?

This program mistakenly defines a function called "color" that returns a "color.Color". The intent was for the return type to refer to the "image/color" package, but of course the name was shadowed by the function itself.

  1. What did you expect to see?
    A non-confusing error message perhaps explaining that "color" is a function or perhaps that "color" refers to itself.
  2. What did you see instead?
prog.go:9: typechecking loop involving color
    prog.go:9 color.Color
    prog.go:9 <T>
    prog.go:9 color
    prog.go:9 <node DCLFUNC>

While technically correct, this error message reads like an internal failure of the type checker, especially since it's outputting internal compiler node names and gives no details about what lines 2 through 5 mean.

/cc @griesemer

Copy link

@griesemer griesemer commented Mar 24, 2016

For the reference: gotype complains with

$ gotype x.go
x.go:9:14: invalid operation: color (value of type func()) has no field or method Color
@griesemer griesemer self-assigned this Mar 24, 2016
Copy link

@ianlancetaylor ianlancetaylor commented Mar 24, 2016

gccgo says

foo.go:9:19: error: expected package
 func color() color.Color {
@bradfitz bradfitz added this to the Unplanned milestone Apr 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants