Re: Reördering SVt_* constants; "internal" SV type
[email protected] ("Paul \"LeoNerd\" Evans") Mon, 29 Jun 2026 23:00:58 +0100
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <[email protected]> |
--Sig_/K7W_IBC5O+WtH/a9b.bd19y Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Thu, 18 Jun 2026 14:45:20 +0200 "H.Merijn Brand" via perl5-porters <[email protected]> wrote: > I am scared it would break a lot of CPAN/XS Actually, having read them over I think a lot of your examples prove my exact point ;) For example: > DBI.xs: if (!SvROK(ref) || SvTYPE(SvRV(ref)) > SVt_PVMG) /* XXX LV */ Yup. This line here is attempting to check that `ref` is definitely a reference to a perl scalar; so it's going to reject anything that isn't ROK or anything whose RV's SvTYPE is greater than SVt_PVMG. But it therefore misses the SVt_PVLV case. In fact its author is even aware of this, having written /* XXX LV */ in the comment there (unless they did mean to write the Roman numbers 30, 53. But I doubt it ;) ) Having skim-read most of the rest of the other examples, I think every single one of them is going to fall foul of the exact issue I am trying to address here. Namely, that they will have a false positive and believe that an SVt_INVLIST is a perl scalar (when in fact it is not), and a false negative and believe that an SVt_PVLV is not a perl scalar (when in fact it is and should be treated as such). I do not believe that the simple adjustment of moving SVt_INVLIST out of that range and moving SVt_PVLV up next to SVt_PVMG is going to change the behaviour of any of these previous comparisons which were already correct, because if they were correct before they'll still be correct afterwards. However, I think it will stand a good chance of suddenly making coincidentally correct a lot of code that previously missed those two edge cases. --=20 Paul "LeoNerd" Evans [email protected] http://www.leonerd.org.uk/ | https://metacpan.org/author/PEVANS --Sig_/K7W_IBC5O+WtH/a9b.bd19y Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iHUEARYKAB0WIQTNysx/4iVoQ8PHpFPM3sWJmDApegUCakLrGgAKCRDM3sWJmDAp eoYzAQDE5t/M6nr8jWkQPicsDQ65QMl5xsYoGsFG1bAb6szDCwD/QnL0hz/kELCv L7PRtVgUQc5OU0uAo+CqUZJDxWvx6Qc= =Cdv3 -----END PGP SIGNATURE----- --Sig_/K7W_IBC5O+WtH/a9b.bd19y--