Comments (10)
This really should not be checking the p
flags. The check that makes the most sense to me would be:
if(SvIOK(sv)){
return TRUE;
}
else if(SvNOK(sv)) {
return S_nv_is_integer(aTHX_ SvNVX(sv));
}
else if(SvPOK(sv)){
return S_pv_is_integer(aTHX_ SvPVX(sv));
}
from p5-type-tiny-xs.
I've pushed out 0.015 which fixes the reported issue and doesn't seem to cause any other problems. Whether or not Type::Tiny::XS should be checking the p flags is an issue for another day.
from p5-type-tiny-xs.
I've reported on Twitter that with Perl versions 5.10, 16, 20, 22, 24, 26, 28, 30 from Dockerhub I get 'No / No / 3.14'. But when I install Type::Tiny::XS the result is 'No / Yes / 3.14' on all of them.
from p5-type-tiny-xs.
Actually, that would allow through some strings like "0e0"
. So to be consistent with the perl implementation, I think the check should be:
if(SvPOK(sv)){
return S_pv_is_integer(aTHX_ SvPVX(sv));
}
else if(SvIOK(sv)){
return TRUE;
}
else if(SvNOK(sv)) {
return S_nv_is_integer(aTHX_ SvNVX(sv));
}
This is basically the same as what is in the released version, except not using the p
flags.
from p5-type-tiny-xs.
Also, it's possible that some of those versions don't have Type::Tiny::XS
installed. One of our devs asked (via company Slack channel):
Do all of those have
Type::Tiny::XS
installed? Pure Perl TT is OK for all my Perls but XS fails on what seems to be a random selection of versions of Perl
And the dev who ran the above confirmed that it appears to be related to Type::Tiny::XS
.
from p5-type-tiny-xs.
Interesting. Pretty sure I stole the Int check from Mouse's XS, so I do wonder if the same bug exists there. Anybody got any thoughts about the best way to do an int check in XS code?
from p5-type-tiny-xs.
Not sure, sorry. You might be able to do this:
int is_IV(SV * maybe_num) {
if(!SvIOK(maybe_num)) return 0;
// extra logic here, but a naïve return 1 works
// if SvIOK really checks if it's an int (see below)
}
But I suspect that might return true if the pIOK
flag is set. Maybe check if SvIOK(maybe_num)
is true and if so, check if SvNOK(maybe_num)
is true and see if the slots have the same value? No idea if that will work or not.
from p5-type-tiny-xs.
Update: I've posted to P5P asking for help. Dave Mitchell and demerphq have been discussing this prior to that. Hopefully something will come from that.
from p5-type-tiny-xs.
I tried stealing code from the latest Mouse release, but that seems even worse, allowing 123\n
and \n123
to pass as integers.
from p5-type-tiny-xs.
I'm actually surprised that SV containing 0e0
can have IOK
flag. It seems that perl 5.6 was the last perl version that did not do this: https://perl.bot/p/7eefti
from p5-type-tiny-xs.
Related Issues (8)
- Possible conflict with Optional in Type::Tiny HOT 2
- MSVC Compiler Compatibility HOT 1
- Type::Tiny::XS crash on Strawberry Perl 5.22 HOT 4
- Bool gives different results on Cpanel::JSON::XS boolean from non-XS version HOT 6
- Stringy zeroes can be accepted as PositiveInts HOT 1
- build failure in 0.016
- Build failure for 0.023 with perl5.28 on debian buster HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5-type-tiny-xs.