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: extraneous quotes in "unexported method or field" error message #18419

Closed
kevinburke opened this issue Dec 23, 2016 · 3 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@kevinburke
Copy link
Contributor

kevinburke commented Dec 23, 2016

Please answer these questions before submitting your issue. Thanks!

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

tip

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

Irrelevant

What did you do?

https://play.golang.org/p/BzZjqEx-Jk

package main

import "net"

func main() {
	d := &net.Dialer{}
	deadline := d.deadline()
}

What did you see instead?

The error message has an extra set of quotes:

d.deadline undefined (cannot refer to unexported field or method net.(*Dialer)."".deadline)

I'd expect it to read:

d.deadline undefined (cannot refer to unexported field or method net.(*Dialer).deadline)
@kevinburke
Copy link
Contributor Author

Relevant code is here in cmd/compile/internal/gc/typecheck.go:

		if n.Left.Op == OTYPE {
			if !looktypedot(n, t, 0) {
				if looktypedot(n, t, 1) {
					yyerror("%v undefined (cannot refer to unexported method %v)", n, n.Sym)
				} else {
					yyerror("%v undefined (type %v has no method %v)", n, t, n.Sym)
				}
				n.Type = nil
				return n
			}

So maybe the problem is in the representation of n.Sym? Also fine with this being closed as "this is expected behavior."

@minux minux changed the title all: extraneous quotes in "unexported method or field" error message? cmd/compile: extraneous quotes in "unexported method or field" error message Dec 23, 2016
@minux minux added this to the Go1.9 milestone Dec 23, 2016
@minux minux added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 23, 2016
@mvdan mvdan self-assigned this May 24, 2017
@gopherbot
Copy link

CL https://golang.org/cl/44070 mentions this issue.

@mvdan
Copy link
Member

mvdan commented May 24, 2017

@kevinburke I've taken a stab at this - feel free to review the CL if you're at all familiar with cmd/compile :)

Also, FYI, you were slightly off in where the error actually occurs. The place is:

case lookdot(n, t, 1) != nil:
        // Field or method matches by name, but it is not exported.
        yyerror("%v undefined (cannot refer to unexported field or method %v)", n, n.Sym)

But I believe this doesn't matter, as the problem is that n.Sym.String() is what includes the weird ."" part. My CL above changes the contents of n.Sym.

@golang golang locked and limited conversation to collaborators Jun 9, 2018
@rsc rsc unassigned mvdan and griesemer Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants