File tree 2 files changed +6
-3
lines changed 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change 6
6
}
7
7
8
8
use strict;
9
- use Test::More tests => 17 ;
9
+ use Test::More tests => 18 ;
10
10
11
11
BEGIN { use_ok(' fields' ); }
12
12
@@ -108,8 +108,10 @@ package main;
108
108
ok(exists $x -> {b }, ' x has b' );
109
109
110
110
SKIP: {
111
- skip " This test triggers a perl bug" , 1 if $] < 5.014001;
111
+ skip " These tests trigger a perl bug" , 1 if $] < 5.014001;
112
112
$x -> {a } = __PACKAGE__ ;
113
113
ok eval { delete $x -> {a }; 1 }, ' deleting COW values' ;
114
+ $x -> {a } = __PACKAGE__ ;
115
+ ok eval { %$x = (); 1 }, ' clearing a restr hash containing COWs' ;
114
116
}
115
117
}
Original file line number Diff line number Diff line change @@ -1554,7 +1554,8 @@ Perl_hv_clear(pTHX_ HV *hv)
1554
1554
for (; entry ; entry = HeNEXT (entry )) {
1555
1555
/* not already placeholder */
1556
1556
if (HeVAL (entry ) != & PL_sv_placeholder ) {
1557
- if (HeVAL (entry ) && SvREADONLY (HeVAL (entry ))) {
1557
+ if (HeVAL (entry ) && SvREADONLY (HeVAL (entry ))
1558
+ && !SvIsCOW (HeVAL (entry ))) {
1558
1559
SV * const keysv = hv_iterkeysv (entry );
1559
1560
Perl_croak (aTHX_
1560
1561
"Attempt to delete readonly key '%" SVf "' from a restricted hash" ,
You can’t perform that action at this time.
0 commit comments