readonly icon indicating copy to clipboard operation
readonly copied to clipboard

Readonly::Clone should recurse past non-readonly top items

Open jimav opened this issue 7 years ago • 0 comments

Currently the Clone deep-walkers abort the search if any non-tied variable is found. This makes cases like the following fail:

Readonly::Hash my %rodata => (topkey => [ {x=>1}, {x=>2}, {x=>3} ]);
my @dataset = @{ $rodata{topkey} };
my $aref = Readonly::Clone @dataset;  # stops prematurely
$aref->[0]->{x] = "newvalue";   #  "attempt to modify read-only data"

The _ARRAY and _HASH subs start with return if !tied(@$arg) etc. and I'm wondering if this is necessary. If they were allowed to continue to recurse, they would find read-only items deeper down.

jimav avatar Apr 30 '18 05:04 jimav