question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

print deprecation warning for bitshift Int by a Long

See original GitHub issue

The current situation is pretty bad:

2.11/Dotty:

scala> 1 << 33L
res0: Long = 8589934592

scala> val x = 1
x: Int = 1

scala> x << 33L
res1: Int = 0

2.12 (since https://github.com/scala/scala/pull/4238):

scala> 1 << 33L
res0: Int = 2

scala> val x = 1
x: Int = 1

scala> x << 33L
res1: Int = 2

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Ichorancommented, Aug 9, 2017

One should write one’s contracts especially carefully when dealing with those who are shifty: spell things out.

0reactions
bishaboshacommented, Mar 29, 2021

so it seems to be that the issue here is not printing the deprecation warning for <<(that: Long)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why doesn't left bit shift << shift beyond 31 for long int datatype?
There is another issue with your intended code: 1L << 63 causes undefined behaviour if long is 64-bit or less. This is because...
Read more >
Left shift (<<) - JavaScript - MDN Web Docs
This operator shifts the first operand the specified number of bits to the left. Excess bits shifted off to the left are discarded....
Read more >
Intrinsics for Integer Bit Shift Operations - Intel
Intrinsics for Integer Bit Shift Operations ; a. first source vector element ; src. source element to use based on writemask result ;...
Read more >
Release Notes — Airflow Documentation
2 we “deprecated” passing an execution date to XCom.get methods, but there was no other option for operator links as they were only...
Read more >
Lua 5.3 Reference Manual
int lua_error (lua_State *L);. Generates a Lua error, using the value at the top of the stack as the error object. This function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found