-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types, types2: gopls crash in recordTypeAndValue #51658
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
Hi, this looks like it could be a type checker bug. Do you recall the code you were working on when this crash occurred? |
Transferring to the go issue tracker. |
CC @griesemer |
Yes. You can remove the word interface next to the FloatType package utils
type FloatType interface {
float32 | float64
}
type IntegerType interface {
int8 | int16 | int32 | int64 | int |
uint8 | uint16 | uint32 | uint64 | uint
}
type ComplexType interface {
complex64 | complex128
}
type Number interface {
FloatType | IntegerType | ComplexType
} |
Thanks for your reply. I'm not able to naively reproduce this. Can you share code that is using FloatType? The error may be occurring at the site of usage. I'll try to look into the panicking stack to see if I can reconstruct. |
I don't use the package utils
func GetDefaultNumber[T Number](value, defaultValue T) T {
if value == 0 {
return defaultValue
}
return value
} |
Thanks, with that function I am able to reproduce! |
Excellent!) |
Minimized reproducer (for types2): package p
type FloatType {
float64
}
func _[T FloatType | int](x T) {
_ = x == 0
} |
Change https://go.dev/cl/392575 mentions this issue: |
@gopherbot please backport this to 1.18, it's a deterministic panic. |
Backport issue(s) opened: #51665 (for 1.18). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
gopls version: v0.8.0 (devel go1.19-c9b60632eb Fri Mar 4 14:10:38 2022 0000)
gopls flags:
update flags: proxy
extension version: 0.32.0
go version: devel 1.19-c9b60632eb
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Sat, 12 Mar 2022 09:33:04 GMT
restart history:
Sat, 12 Mar 2022 09:24:24 GMT: activation (enabled: true)
ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.
Describe what you observed.
OPTIONAL: If you would like to share more information, you can attach your complete gopls logs.
NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.
<OPTIONAL: ATTACH LOGS HERE>
The text was updated successfully, but these errors were encountered: