-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Inconsistent unsigned -> signed RangeDefect usage across integer sizes #15210
Labels
Comments
narimiran
pushed a commit
that referenced
this issue
Sep 11, 2020
mildred
pushed a commit
to mildred/Nim
that referenced
this issue
Jan 11, 2021
* fixes nim-lang#15210 [backport:1.2] * use patched version of bigints library
Araq
added a commit
that referenced
this issue
Feb 24, 2021
* fixes #15210 [backport:1.2] * make tests green * make ordinal work * makes Swapable test compile * make Indexable example work * concepts: 'self' is now 'Self' * concepts: make Dictionary example compile * document the new concept implementation * concepts: make typeDesc work properly * concepts: allow documentation comments (d'oh)
This was referenced Feb 24, 2021
This was referenced Mar 10, 2021
Closed
ringabout
pushed a commit
to ringabout/Nim
that referenced
this issue
Mar 22, 2021
* fixes nim-lang#15210 [backport:1.2] * make tests green * make ordinal work * makes Swapable test compile * make Indexable example work * concepts: 'self' is now 'Self' * concepts: make Dictionary example compile * document the new concept implementation * concepts: make typeDesc work properly * concepts: allow documentation comments (d'oh)
narimiran
added a commit
that referenced
this issue
Mar 22, 2021
ardek66
pushed a commit
to ardek66/Nim
that referenced
this issue
Mar 26, 2021
* fixes nim-lang#15210 [backport:1.2] * make tests green * make ordinal work * makes Swapable test compile * make Indexable example work * concepts: 'self' is now 'Self' * concepts: make Dictionary example compile * document the new concept implementation * concepts: make typeDesc work properly * concepts: allow documentation comments (d'oh)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Converting
uint8
,uint16
, anduint32
to, respectively,int8
,int16
, andint32
values out of range of the target type results in aRangeError
, but converting auint64
outside of signed 64-bit range toint64
behaves differently, apparently reinterpreting the bit pattern in place, with no error. This seems a less-than-optimal level of internal consistency.This comes up in status-im/nimbus-eth2#1544.
Example
For
uint8
/int8
:For
uint16
/int16
:For
uint32
/int32
:For
uint64
/int64
:Current Output
Expected Output
One path to consistency would probably be:
Additional Information
I tested this on Nim 1.2.6:
With identical results except that
RangeDefect
was spelledRangeError
.For Nim 1.0.4:
It was the same as 1.2.6, except that the
RangeError
messages did not display the allowed range of values for each type.Nim 0.19.4:
Behaves exactly the same for these examples as Nim 1.0.4.
#12554 is related, but different because it focuses on narrowing unsigned -> unsigned integer conversions. There are still non-overlapping ranges here, but neither type's range is a superset of the other, and no one behavior exists across all the supported integer sizes. Whatever the desired behavior, it should probably be the same across, at least, 32 and 64-bit integers.
The text was updated successfully, but these errors were encountered: