]> git.vpit.fr Git - perl/modules/Variable-Temp.git/commitdiff
'temp $scalar;' should undef $scalar
authorVincent Pit <vince@profvince.com>
Wed, 1 Apr 2015 17:11:18 +0000 (14:11 -0300)
committerVincent Pit <vince@profvince.com>
Wed, 1 Apr 2015 17:11:18 +0000 (14:11 -0300)
lib/Variable/Temp.pm
t/20-lvalue.t

index 5be8073853f332eaf3493bf28263b6e0f20bfba1..390ff48327278330812ca2559bbde170acda0a29 100644 (file)
@@ -113,7 +113,8 @@ sub temp (\[$@%]) :lvalue {
  } else { # $type eq 'SCALAR' || $type eq 'REF'
   my $save = $$var;
   &Scope::Upper::reap(sub { $$var = $save } => $target);
  } else { # $type eq 'SCALAR' || $type eq 'REF'
   my $save = $$var;
   &Scope::Upper::reap(sub { $$var = $save } => $target);
-  $ret = $var;
+  $$var = undef;
+  $ret  = $var;
  }
  $$ret;
 }
  }
  $$ret;
 }
index 90da2a98b24f520ef30cca056d04f06c1798af85..e9a3850f979b0908b792c06f01d7e4d0e2b73d41 100644 (file)
@@ -9,7 +9,7 @@ use Test::More;
 
 BEGIN {
  if ("$]" >= 5.014) {
 
 BEGIN {
  if ("$]" >= 5.014) {
-  plan tests => 7 + 13;
+  plan tests => 9 + 15;
  } else {
   plan skip_all => 'perl 5.14 required to lvalue assignment with prototype \[$@%]';
  }
  } else {
   plan skip_all => 'perl 5.14 required to lvalue assignment with prototype \[$@%]';
  }
@@ -31,6 +31,11 @@ is $x, 1;
  is $x, 3;
 }
 is $x, 1;
  is $x, 3;
 }
 is $x, 1;
+{
+ temp $x;
+ is $x, undef;
+}
+is $x, 1;
 
 our $y = 1;
 is $y, 1;
 
 our $y = 1;
 is $y, 1;
@@ -65,3 +70,8 @@ is $y, 1;
  is $y, 3;
 }
 is $y, 1;
  is $y, 3;
 }
 is $y, 1;
+{
+ temp $y;
+ is $y, undef;
+}
+is $y, 1;