-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types: no way to construct the signature of append(s, "string"...) via the API #55030
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
I agree that (2) is the best solution, and (4) is a good short-term workaround. |
Change https://go.dev/cl/430455 mentions this issue: |
Or: maybe the built-in Just as there are cases where you can use an untyped That suggests, perhaps, adding a Then there wouldn't be a corresponding call to |
This is about creating a signature for |
Agreed, upon further consideration I think that's the clear best solution. |
this PR alias string T not support for x/tools/go/ssa
|
@visualfc I'm not sure I understand. That CL fixes the panic in go/types, by allowing constructing the signature of |
this PR allow basic string. but
|
@visualfc I see now, thanks. You're right, this CL needs to consider the core type. |
@findleyr test this PR ~[]byte panic. coreType(last) is []byte.
|
@visualfc thank you, you are right. Please comment on the CL though. |
Do we know which versions the fix will land in go/types? If it is in 1.20 and later, x/tools/go/ssa will need a workaround to support 1.19 and 1.18. |
The current plan is 1.20 but we could easily do a back port, I think. |
Thinking through the backport question: If we backport to, say, 1.18, then x/tools/go/ssa will deterministically panic at 1.18 versions before 1.18.8. It's sort of like go/ssa is using an API that was added in 1.18.8... ...but what is the alternative? Generating different instructions (option 3) is a non-starter, I think, now that we've decided to fix go/types. The hack in option 4 is liable to be fragile. Doing nothing means go/ssa can panic on valid generic code before go 1.20. None of the alternatives is desirable, and the backport is trivially safe, so I vote yes to backport. |
@gopherbot please consider this for backport to 1.18 and 1.19, it is a bug that |
Backport issue(s) opened: #55148 (for 1.18), #55149 (for 1.19). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
@griesemer if you agree, can you please create cherry-picks of your CL to 1.18 and 1.19? Thanks. |
Discovered in a discussion with @timothy-king about #54946: when type checking the following package, we record the type of append as
func([]byte, string...) []byte
:However, there is no way to construct
func([]byte, string...) []byte
via go/types APIs.NewSignatureType
panics withvariadic parameter must be of unnamed slice type
. This has never mattered before because this type cannot appear in export data, but it matters forx/tools/go/ssa
, which must do substitution inside function bodies.What should we do about this?
Let's discuss. I would lean toward (2) or (4). This doesn't seem worth a new API (though the limitation should perhaps be more clearly documented).
CC @griesemer @adonovan @timothy-king
The text was updated successfully, but these errors were encountered: