From: Vincent Pit Date: Wed, 1 Apr 2015 17:11:18 +0000 (-0300) Subject: 'temp $scalar;' should undef $scalar X-Git-Tag: v0.02~4 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=01a4daa0f14207acfeff236b5381e3dfebe1b981;p=perl%2Fmodules%2FVariable-Temp.git 'temp $scalar;' should undef $scalar --- diff --git a/lib/Variable/Temp.pm b/lib/Variable/Temp.pm index 5be8073..390ff48 100644 --- a/lib/Variable/Temp.pm +++ b/lib/Variable/Temp.pm @@ -113,7 +113,8 @@ sub temp (\[$@%]) :lvalue { } else { # $type eq 'SCALAR' || $type eq 'REF' my $save = $$var; &Scope::Upper::reap(sub { $$var = $save } => $target); - $ret = $var; + $$var = undef; + $ret = $var; } $$ret; } diff --git a/t/20-lvalue.t b/t/20-lvalue.t index 90da2a9..e9a3850 100644 --- a/t/20-lvalue.t +++ b/t/20-lvalue.t @@ -9,7 +9,7 @@ use Test::More; 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 \[$@%]'; } @@ -31,6 +31,11 @@ is $x, 1; is $x, 3; } is $x, 1; +{ + temp $x; + is $x, undef; +} +is $x, 1; our $y = 1; is $y, 1; @@ -65,3 +70,8 @@ is $y, 1; is $y, 3; } is $y, 1; +{ + temp $y; + is $y, undef; +} +is $y, 1;