Skip to content

Readonly behaves unexpectedly when using defined-or signatures #44

@plentyofcoffee

Description

@plentyofcoffee

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions