Code Monkey home page Code Monkey logo

Comments (10)

haarg avatar haarg commented on June 25, 2024 2

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.

tobyink avatar tobyink commented on June 25, 2024 2

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.

Tekki avatar Tekki commented on June 25, 2024 1

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.

haarg avatar haarg commented on June 25, 2024 1

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.

Ovid avatar Ovid commented on June 25, 2024

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.

tobyink avatar tobyink commented on June 25, 2024

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.

Ovid avatar Ovid commented on June 25, 2024

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.

Ovid avatar Ovid commented on June 25, 2024

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.

tobyink avatar tobyink commented on June 25, 2024

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.

xenu avatar xenu commented on June 25, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.