-
-
Notifications
You must be signed in to change notification settings - Fork 113
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
format: panic when using type parameters (via gopls) #149
Comments
Thanks for filing this! I've been closely following @findleyr's work on golang/go#47781. It landed recently, and just got accepted. So I'll get on updating gofumpt as soon as I can, as I think the APIs are pretty final at this point. |
Huh, there is handling for this (and has been for a while): I'm also not reproducing with the repro given here. I think this panic could be possible if we're somehow getting a node of type *ast.IndexListExpr with nil pointer, but I'm not seeing anything in gofumpt that would cause this. Will need to look more later. |
I could reproduce with x/tools v0.1.7 and
After updating to the latest master as of today, I can no longer reproduce the crash. I think https://go-review.googlesource.com/c/tools/+/352898 might have been the fix. It's that default case in the type switch that we were panicking on, and the IndexListExpr type in question is now handled explicitly. It's unclear to me why only gofumpt was running into a panic with the older code. I guess I'm not too worried on my end, as long as master works :) I'll lock it in via a test, too. |
I've included the test and the fix in master now. Undoing the update reproduces the panic, too. |
@mvdan this is expected to fail at x/tools@v0.1.7: that version temporarily guarded use of the new APIs behind a type parameter, so that we don't break the build with API changes. We'll tag an x/tools using the APIs once the 1.18 APIs are stable (which might not be for some time, as there are a few late amendments to generics being proposed). I would actually have expected this to be fixed before https://go-review.googlesource.com/c/tools/+/352898, which was (mostly) an API cleanup (it differs in the case of a typed nil). Anyway, I currently consider the astutil package to be fully updated with generics support; please let me know if you encounter any further problems. |
Sounds good. I think my needs are met at this point, as gofumpt does not use go/types :) |
Using
gofumpt
viagopls
and saving a file that includes a function call with type parameters:Results in a panic in
x/tools
:The text was updated successfully, but these errors were encountered: