-
Notifications
You must be signed in to change notification settings - Fork 1.1k
print deprecation warning for bitshift Int by a Long #2968
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
To clarify, I find it highly implausible that someone would go to the trouble of making the RHS of a shift be |
Just wanted to point out that shifting by constant doesn't have to be explicit or obvious. It could be an inherited constant value, etc, so the expression doesn't necessarily indicate an intention to widen.
Also, if you name an operation shift, then you must expect it to be shifty. |
One should write one's contracts especially carefully when dealing with those who are shifty: spell things out. |
My opinion on the matter:
|
The differing behavior in the presence of a constant was a plain bug of the constant folder, fixed in the PR you mentioned. There was, independently, the problem of widening, which was inconsistent with Java and which I fixed in scala/scala#5117. I think it would be reasonable to deprecate and eventually remove the Int shift Long overload, even in 2.x. |
I agree with @DarkDimius , should be deprecated in Scala2 but removed in Scala3. Implicit number conversions should never happen when doing bitshifts, because they are pretty much never what you want |
Harmonized at #6366
vs
|
so it seems to be that the issue here is not printing the deprecation warning for |
I just tried this out and it does seem to print out the deprecation warning. ![]() //> using scala 3.nightly
//> using option -deprecation
object example:
val a = 1 << 33L Am I correct in understanding then that this can be closed? Also confirmed that the other one @som-snytt pointed out also warns: ![]() |
Yes, looks like it can be closed. |
The current situation is pretty bad:
2.11/Dotty:
2.12 (since scala/scala#4238):
See also the discussion at https://gitter.im/scala/contributors?at=598b4b3eee5c9a4c5fa61568 where @Ichoran proposed getting rid of
Int#<<(x: Long)
since it can be so easily misused.The text was updated successfully, but these errors were encountered: