Change 31301 by [EMAIL PROTECTED] on 2007/05/29 08:41:09

        Subject: Re: localising hash element by variable
        From: Bo Lindbergh <[EMAIL PROTECTED]>
        Date: Mon, 28 May 2007 20:26:00 +0200
        Message-Id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/scope.c#209 edit
... //depot/perl/t/op/local.t#34 edit

Differences ...

==== //depot/perl/scope.c#209 (text) ====
Index: perl/scope.c
--- perl/scope.c#208~31107~     2007-04-30 02:22:58.000000000 -0700
+++ perl/scope.c        2007-05-29 01:41:09.000000000 -0700
@@ -545,7 +545,7 @@
     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);

==== //depot/perl/t/op/local.t#34 (xtext) ====
Index: perl/t/op/local.t
--- perl/t/op/local.t#33~29938~ 2007-01-23 14:54:00.000000000 -0800
+++ perl/t/op/local.t   2007-05-29 01:41:09.000000000 -0700
@@ -5,7 +5,7 @@
     @INC = qw(. ../lib);
     require './test.pl';
 }
-plan tests => 114;
+plan tests => 117;
 
 my $list_assignment_supported = 1;
 
@@ -428,3 +428,18 @@
     
 }
 
+# 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);
+}
+
End of Patch.

Reply via email to