Tighten semantics of numeric#32
Conversation
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
Signed-off-by: Fengyun Liu <fengyun.liu.cs@gmail.com>
This is for future-proof: if we ever go to even bigger literals.
|
@Radeonares32 This PR fixes the semantics of |
|
Thanks, this is a nice cleanup. I found a couple of backend issues before approval:
Minor: |
|
Thank you very much, @Radeonares32 . I've addressed your feedback and added tests to prevent regression. |
Summary
The type
Intis currently up to platform interpretation, it creates portability concerns similar to C.What has changed
Intto 32 bitsLongfor 64 bits/and%(matters when negative numbers involved)Byteto be unsigned (same as in C#)~forIntandLongAlternative
We could follow Ruby/Python to make infinite precision integer as the default, and introduce int32 and int64 separately. That is a reasonable design for usability.
However, it makes language interoperability for Java/JS complex: an int literal
3is no longer the default type of the target platform. Given that the use case of infinite precision arithmetic is rare, we need to optimize for platform interoperability here.Testing
tests/pos/ortests/warn/./cilocally and all tests passHow to sign off commits
Use
git commit -sto add theSigned-off-byline automatically:To add a sign-off to the last commit retroactively:
To add sign-off to the last 3 commits:
Security impact
No