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: inaccurate column number for parameters #23031

Closed
cherrymui opened this issue Dec 7, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@cherrymui
Copy link
Contributor

commented Dec 7, 2017

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

tip (1b9f663)

Does this issue reproduce with the latest release?

yes

What did you do?

It seems that the column numbers for parameters are not accurate. Different parameters may get same line and column numbers, as seen in #23020.

I've come up a simple example:

package p

//            15     22
//            |      |
func f(x int, x int) int {
	return 3
}

What did you expect to see?

/tmp/x5.go:5:15: duplicate argument x

What did you see instead?

$ go tool compile /tmp/x5.go 
/tmp/x5.go:5:22: duplicate argument x

It seems we don't emit column numbers for variables in DWARF -- if we do, that might be also inaccurate.

@odeke-em

This comment has been minimized.

Copy link
Member

commented Dec 7, 2017

@mdempsky mdempsky added this to the Go1.11 milestone Dec 7, 2017

@mdempsky

This comment has been minimized.

Copy link
Member

commented Dec 7, 2017

I was looking at this the other day. The issue is we setup the ONAME Nodes to represent the parameters with the position information where the identifiers appeared, but then when we call funcargs (and in turn declare), that information gets clobbered with lineno (which happens to be at the last token in the function signature, the int return parameter type).

I think the proper fix is that gc.declare needs to stop clobbering n.Pos, and to just require that callers always setup n.Pos correctly. I think this is almost already the case, but needs a review.

@griesemer griesemer added the NeedsFix label Jun 27, 2018

@griesemer

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2018

This appears to be fixed. I cannot reproduce this.

@griesemer griesemer closed this Jun 27, 2018

@odeke-em

This comment has been minimized.

Copy link
Member

commented Jun 27, 2018

@griesemer in deed, this bug was fixed by CL 104275 aka commit 26e0e8a and precisely this line deletion in dcl.go 26e0e8a#diff-af57b81069f33da91c083d4d5b61aeeeL80
screen shot 2018-06-27 at 1 42 34 pm

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.