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: Incorrect error following named pointer dereference on field #11790
Comments
Marking as 1.5 because this is a failure to compile a valid program. CC @rsc |
This was introduced as part of the fix to #9017 by @paranoiacblack. @dr2chase is looking into it. |
The root cause is the original sin of an AST that isn't really a tree. Because "q" is shared by different expressions, when it is marked "implicit" in one, it becomes "implicit" in another. I added tracing at the obvious places in the patch for #9017 ( b59dd94 ). Note the mark-implicit on line 23 (q) and the error on 24 (because q is now implicit)
But both actions are necessary for the 9017 test to pass (at line 53, specifically):
So, I think we roll back the fix to 9017? |
CL https://golang.org/cl/12532 mentions this issue. |
With this change the compiler again allows the implicit dereference |
Do you have a test case demonstrating the revert? I did not revert the change; I attempted to correct it, and the regression test for 9017 still passes. |
My apologies. I think I must have gotten confused about which version of Go I was running. I recompiled from master and then I think I used the terminal that was still running 1.4. The test case I had is correctly reporting the |
The fix to prevent incorrect dereference of a named pointer type on a method prevents an explicit dereference, but only when it follows a dereference of a field.
This relates to 40818cf and I am seeing the problem with
go version go1.5beta2 darwin/amd64
.The following program (similar to the example in the Spec section on Selectors) gives the error
q.M0 undefined
. Strangely, this error only appears after first referencingq.x
. If theq.x
line is commented out, the following line succeeds. Reverse the order of the lines (putq.x
after(*q).T0.M0()
) and the program compiles and works!What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: