-
Notifications
You must be signed in to change notification settings - Fork 26
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
Can and should unconvert simplify this case? #7
Comments
Nice, I agree the type conversions there are unnecessary because of context, just like in
It should also work the same for struct and map literals. |
Great! As I understand, this will only be possible in some cases. For example, if it looks like this: var x, y, z = 1, 2, 3
s := []int32{
int32(x),
int32(y),
int32(z),
4,
5,
} Then it won't be possible, since variables
Yep. Also arrays. I didn't mention others because I wanted to start the conversation simpler. |
Correct, in the |
I suspect this issue is also related to #20 (comment). Specifically, it could be that the reason this case isn't detected and reported because the constants would become untyped as a result. |
Going to close as a duplicate of #20 since the latter has more details. |
Suppose there's a declaration of a
[]int32
slice done in the following way:Is there a reason
unconvert
can't or shouldn't simplify it to:Since constants are used, the type conversion is not needed, as the constants will have their types inferred correctly from the context. Any thoughts?
The text was updated successfully, but these errors were encountered: