-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: suboptimal error for &T{} literal mismatch #26855
Comments
It is also odd because without the parentheses, the phrase
|
CC: @randall77 @griesemer |
It should say |
typecheckcomplit makes a copy (typecheck.go:2915) of the complit node it type-checks and then modifies its Op in place. Because n.Orig points to n, this implicitly modifies also n.Orig. During printing, the original node doesn't have the correct Op anymore leading to this error. |
Change https://golang.org/cl/136395 mentions this issue: |
Change https://golang.org/cl/136396 mentions this issue: |
Found while tracking down #26855. Change-Id: Ice137fe390820ba351e1c7439b6a9a1b3bdc966b Reviewed-on: https://go-review.googlesource.com/136396 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Change https://golang.org/cl/136540 mentions this issue: |
Node.copy used to make a shallow copy of a node. Often, this is not correct: If a node n's Orig field pointed to itself, the copy's Orig field has to be adjusted to point to the copy. Otherwise, if n is modified later, the copy's Orig appears modified as well (because it points to n). This was fixed for one specific case with https://go-review.googlesource.com/c/go/+/136395 (issue #26855). This change instead addresses copy in general: In two cases we don't want the Orig adjustment as it causes escape analysis output to fail (not match the existing error messages). rawcopy is used in those cases. In several cases Orig is set to the copy immediately after making a copy; a new function sepcopy is used there. Updates #26855. Fixes #27765. Change-Id: Idaadeb5c4b9a027daabd46a2361348f7a93f2b00 Reviewed-on: https://go-review.googlesource.com/136540 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Does this issue reproduce with the latest release?
In the playground, yes.
What did you do?
https://play.golang.org/p/uQjX9qTwBz1
What did you expect to see?
An error message pointing out the
T
vs.*T
type problem.What did you see instead?
The error message is there, but it is phrased oddly.
cannot use T literal
is confusing. I'm using a&T literal
. If you put aside the parenthetical for a moment, the oddness is apparent:cannot use T literal as type T in field value
. I think this error message could be improved.The text was updated successfully, but these errors were encountered: