Message-Id: <
BC2C451F-B286-4D38-923E-E3B473F7B5E1@hagernas.com>
p4raw-id: //depot/perl@31301
SvGETMAGIC(*sptr);
SSCHECK(4);
SSPUSHPTR(SvREFCNT_inc_simple(hv));
- SSPUSHPTR(SvREFCNT_inc_simple(key));
+ SSPUSHPTR(newSVsv(key));
SSPUSHPTR(SvREFCNT_inc(*sptr));
SSPUSHINT(SAVEt_HELEM);
save_scalar_at(sptr);
@INC = qw(. ../lib);
require './test.pl';
}
-plan tests => 114;
+plan tests => 117;
my $list_assignment_supported = 1;
}
+# when localising a hash element, the key should be copied, not referenced
+
+{
+ my %h=('k1' => 111);
+ my $k='k1';
+ {
+ local $h{$k}=222;
+
+ is($h{'k1'},222);
+ $k='k2';
+ }
+ ok(! exists($h{'k2'}));
+ is($h{'k1'},111);
+}
+