-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types, types2: writeType does not invoke Qualifier when printing an unsafe.Pointer #44515
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
Comments
This seems reasonable to me. Given that this logic predates https://golang.org/cl/11692 adding the Qualifier function, perhaps this was just an oversight. CC @griesemer |
Change https://golang.org/cl/295271 mentions this issue: |
Thanks for pointing this out; I think @findleyr is correct, this looks like an oversight. Fix is out. |
Change https://golang.org/cl/296289 mentions this issue: |
The go/types fix for golang/go#44515 changed the type string for unsafe.Pointer from a fixed "unsafe.Pointer" to a customizable package path followed by "Pointer" (the customization was in place for any other object already). The package path customization is done through a user-provider types.Qualifier function. If none is provided, the ordinary package path is used ("unsafe"). Guru provides a package-relative qualifier which leaves away the package path if an object is local to a package. As a result, unsafe.Pointer is printed as "Pointer" which breaks an existing test. Provide no qualifier function when printing a type from package unsafe instead (there's only unsafe.Pointer). Since no qualifier was used in the past, this Guru-specific change will also work when run using earlier Go versions. Fixes golang/go#44596. Updates golang/go#44515. Change-Id: I3c467e4ed09aa13deb50368fe98e42c723a6376b Reviewed-on: https://go-review.googlesource.com/c/tools/+/296289 Trust: Robert Griesemer <[email protected]> Run-TryBot: Robert Griesemer <[email protected]> gopls-CI: kokoro <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
Because
unsafe.Pointer
is a*types.Basic
, the type stringifier uses a special case to print the package name:As written, this does not allow a given Qualifier function to run and control how the package name is printed, which means that anything which wants to print something other than
"unsafe"
must do so by also special casingunsafe.Pointer
.Is there any reason not to use the Qualifier function in
writeType
when printingunsafe.Pointer
? This would be a very quick change, but I wanted to make sure the current functionality isn't deliberate before opening a CL.The text was updated successfully, but these errors were encountered: