Readonly v2.05
use v5.36; # enable strict, warnings, and signatures
use Readonly;
sub f($v //= '') {
die 'empty!' if !length $v;
$v;
}
Readonly my $s => 'test';
# chomp $s;
say f($s);
I would expect the code above to print "test". Instead, it dies with the empty! message. Uncommenting line 10, or otherwise using the variable as a string before passing it to the f function, produces the expected result.
The Readonly::Scalar function does not exhibit this same behavior.