diff options
Diffstat (limited to 't/op/tie.t')
-rwxr-xr-x | t/op/tie.t | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/t/op/tie.t b/t/op/tie.t index 7e45615aff..f30f69336d 100755 --- a/t/op/tie.t +++ b/t/op/tie.t @@ -405,3 +405,44 @@ Two 4 Three 4 +######## +# [perl #22297] cannot untie scalar from within tied FETCH +my $counter = 0; +my $x = 7; +my $ref = \$x; +tie $x, 'Overlay', $ref, $x; +my $y; +$y = $x; +$y = $x; +$y = $x; +$y = $x; +#print "WILL EXTERNAL UNTIE $ref\n"; +untie $$ref; +$y = $x; +$y = $x; +$y = $x; +$y = $x; +#print "counter = $counter\n"; + +print (($counter == 1) ? "ok\n" : "not ok\n"); + +package Overlay; + +sub TIESCALAR +{ + my $pkg = shift; + my ($ref, $val) = @_; + return bless [ $ref, $val ], $pkg; +} + +sub FETCH +{ + my $self = shift; + my ($ref, $val) = @$self; + #print "WILL INTERNAL UNITE $ref\n"; + $counter++; + untie $$ref; + return $val; +} +EXPECT +ok |