Skip to content
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

fix Int check on large unsigned integers #9

Merged
merged 1 commit into from
Sep 5, 2019
Merged

Conversation

haarg
Copy link
Contributor

@haarg haarg commented Sep 3, 2019

Large unsigned integers can't always be converted to floats without
losing precision. Checking the NOKp flag and then the NV flag will end
up checking against an inaccurate value and won't register as an
integer.

The p flags should not be used for type checking, as they represent
that any value exists in the related slot. Their value may not be
accurate.

POK is still checked first, as values like '0e0' will set the IOK flag
if used as a number.

Large unsigned integers can't always be converted to floats without
losing precision.  Checking the NOKp flag and then the NV flag will end
up checking against an inaccurate value and won't register as an
integer.

The `p` flags should not be used for type checking, as they represent
that any value exists in the related slot.  Their value may not be
accurate.

POK is still checked first, as values like '0e0' will set the IOK flag
if used as a number.
@haarg
Copy link
Contributor Author

haarg commented Sep 3, 2019

I've only made changes here to the Int check. There are a number of other related checks that should be changed to stop checking the p flags.

gugod added a commit to gugod/p5-Mouse that referenced this pull request Sep 4, 2019
As @haarg demonstrated in tobyink/p5-type-tiny-xs#9,
previous "fix" breaks for large unsigned integers.

@haarg also pointed out that macro ended with "p" such as SvIOKp should be avoided,
since that check the flag for ["non-public integer values"][1], and the one without p ("SvIOK")
checks the flag for ["public integer values"][2]

[1]: https://perl5.git.perl.org/perl.git/blob/HEAD:/sv.h#l369
[2]: https://perl5.git.perl.org/perl.git/blob/HEAD:/sv.h#l364
@tobyink tobyink merged commit e71617b into tobyink:master Sep 5, 2019
@tobyink
Copy link
Owner

tobyink commented Sep 5, 2019

Released as 0.016.

(Probably some of the recent Int fixes could be applied to PositiveInt and PositiveOrZeroInt too, but for the time being, it's good to at least have them on Int.)

clrpackages pushed a commit to clearlinux-pkgs/perl-Type-Tiny-XS that referenced this pull request Oct 14, 2019
0.016	2019-09-05

 [ Bug Fixes ]
 - Fix Int check on large unsigned integers.
   Graham Knop++
   <tobyink/p5-type-tiny-xs#9>

0.015	2019-09-03

 [ Bug Fixes ]
 - Casting a non-integer number to an integer elsewhere mistakenly caused
   the Int check to think the non-integer was an integer.
   Curtis "Ovid" Poe++
   <tobyink/p5-type-tiny-xs#8>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Nov 2, 2019
0.016   2019-09-05
 [ Bug Fixes ]
  - Fix Int check on large unsigned integers.
    Graham Knop++
   <tobyink/p5-type-tiny-xs#9>

0.015   2019-09-03
 [ Bug Fixes ]
  - Casting a non-integer number to an integer elsewhere mistakenly caused
    the Int check to think the non-integer was an integer.
    Curtis "Ovid" Poe++
    <tobyink/p5-type-tiny-xs#8>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants