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
Deprecate numeric widening of numeric literals which are not representable with Float/Double #8757
Deprecate numeric widening of numeric literals which are not representable with Float/Double #8757
Conversation
I forgot to do the same check for Doubles, working on that now. |
…table with Float/Double
c8cb24b
to
e88a7cb
Compare
How does it compare to #8730 ? |
@som-snytt i don't have enough knowledge of the compiler to answer that question. I could add your tests to my solution to check if they also warn. |
(context: https://twitter.com/darjutak/status/1232599151537512448, we're on the left in the first photo. i missed / didn't remember your PR, @som-snytt) |
Thanks, I see. Previously, I was only reading tpolecat on twitter, but now I will also read darjutak. I may even read darjutak first. Maybe we could use a spree tag here. The "roundtrip" test in the other PR, borrowed from doti, is more generous. |
But with the roundtrip you will have Integer values which are okay, but the value one bigger or one smaller would not be okay. In my opinion it's nicer to war a soon as you start to truncate. |
Yes, I don't have a strong opinion about the ergonomics. I was trying to "align with doti" a bit, but dotty has sharp edges, such as The use case is if I can get my integral value out again, for example it's a sentinel, then there is no reason to warn. If I am computing with it, the opinion on the other ticket was not to warn about operations; I asked why is What is the use case for warning about conversion to a float that is never used in a computation? I computed an int, but my spreadsheet report generator only takes a float? The doti use case is just about the type inference. |
Co-authored-by: A. P. Marki <som.snytt@gmail.com>
@lrytz @som-snytt thanks for your work! |
Thanks for your contribution and the friendly pair-coding! |
follow up for: #8679
fixes scala/bug#10773