Skip Menu |

This queue is for tickets about the Type-Tiny CPAN distribution.

Report information
The Basics
Id: 132426
Status: resolved
Priority: 0/
Queue: Type-Tiny

People
Owner: Nobody in particular
Requestors: haarg [...] haarg.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.010002



Subject: Undeclared dependency on Scalar::Util 1.18
The implementation of Num uses Scalar::Util::looks_like_number to check if the value is a number. The tests then check globs against this. Until Scalar::Util 1.18, looks_like_number would return true for globs.
On 2020-04-26T16:53:10+01:00, haarg wrote: Show quoted text
> The implementation of Num uses Scalar::Util::looks_like_number to > check if the value is a number. The tests then check globs against > this. Until Scalar::Util 1.18, looks_like_number would return true > for globs.
Okay, so the lax check for Num is: defined($x) and !ref($x) and looks_like_number($x) I don't really want to require Scalar::Util 1.18, so would this work? defined($x) and ref(\$x) eq 'SCALAR' and looks_like_number($x)
There are two other potential returns from ref to consider. LVALUE can happen if the variable is an alias to the return from substr. As long as you are operating on a copy of the value rather than an alias, this isn't an issue. The second is VSTRING. The value v50.49.57 is equivalent to the string "219", but with magic attached. Even with copies of the value, ref \$vstring will return 'VSTRING'.
So... defined($x) and do { ref(\$x) eq 'SCALAR' or ref(\(my $val = $x)) eq 'SCALAR' } and looks_like_number($x) That weird jumping-through-hoops ref check is already done for strings anyway.
Oh no, you already said that won't work for vstrings. I'm not really sure what the best behaviour should be for those.
Since globs seem to be the only problem here, you could just do a check for ref \$x ne 'GLOB' instead.
Fixed in repository
Fix will be released to CPAN tomorrow.