Re: [perl #7615] (if|unless) ( local ... ) not undone
On Fri, Aug 26, 2005 at 09:06:50AM -0700, Steve Peters via RT wrote: $a = 10; if (local $a = 1){ } print $a; # Should be 10, not 1 Still busted in 5.8.6 and blead. $ bleadperl -wle '$a = 10; if( local $a = 1 ) {} print $a' Found = in conditional, should be == at -e line 1. 1 $ bleadperl -wle '$a = 10; if( my $a = 1 ) {} print $a' Found = in conditional, should be == at -e line 1. 10 -- Michael G Schwern [EMAIL PROTECTED] http://www.pobox.com/~schwern 'All anyone gets in a mirror is themselves,' she said. 'But what you gets in a good gumbo is everything.' -- Witches Abroad by Terry Prachett
Re: [perl #7615] (if|unless) ( local ... ) not undone
On Fri, Aug 26, 2005 at 09:06:50AM -0700, Steve Peters via RT wrote: [EMAIL PROTECTED] - Mon Sep 03 10:43:30 2001]: - Local variables declared in a conditional expression of a conditional block are not restored at the end of scope. $a = 10; if (local $a = 1){ } print $a; # Should be 10, not 1 Applies to local variables declared in 'if (expr)', 'unless(expr)', and 'elsif (expr)'. Lexical variables are okay, as are local variables in the conditional expression of a loop block. This behavior has been fixed in bleadperl by not allowing it. ./perl rt_7615.pl Can't localize lexical variable $a at rt_7615.pl line 4. $a isn't a lexical variable in the example, so that doesn't fix it. Ronald
[perl #7615] (if|unless) ( local ... ) not undone
[EMAIL PROTECTED] - Mon Sep 03 10:43:30 2001]: - Local variables declared in a conditional expression of a conditional block are not restored at the end of scope. $a = 10; if (local $a = 1){ } print $a; # Should be 10, not 1 Applies to local variables declared in 'if (expr)', 'unless(expr)', and 'elsif (expr)'. Lexical variables are okay, as are local variables in the conditional expression of a loop block. This behavior has been fixed in bleadperl by not allowing it. ./perl rt_7615.pl Can't localize lexical variable $a at rt_7615.pl line 4.
[perl #7615] (if|unless) ( local ... ) not undone
Steve Peters wrote This behavior has been fixed in bleadperl by not allowing it. ./perl rt_7615.pl Can't localize lexical variable $a at rt_7615.pl line 4. No it hasn't.I suspect you did the wrong test - what's that lexical doing in the error message? When I try perl5.8.6 -w $a = 10; if (local $a = 1){ } print $a; # Should be 10, not 1 __END__ Found = in conditional, should be == at - line 2. 1 the bug is still present. I presume this is another manifestation of the fact that a conditional involves *two* scopes, one including the condition and one not. Perl conflates them, with unfortunate results. I presume the resaon for conflating them is efficiency. Mike Guy
[perl #7615] (if|unless) ( local ... ) not undone
[EMAIL PROTECTED] - Fri Aug 26 09:47:17 2005]: Steve Peters wrote This behavior has been fixed in bleadperl by not allowing it. ./perl rt_7615.pl Can't localize lexical variable $a at rt_7615.pl line 4. No it hasn't.I suspect you did the wrong test - what's that lexical doing in the error message? When I try perl5.8.6 -w $a = 10; if (local $a = 1){ } print $a; # Should be 10, not 1 __END__ Found = in conditional, should be == at - line 2. 1 the bug is still present. I presume this is another manifestation of the fact that a conditional involves *two* scopes, one including the condition and one not. Perl conflates them, with unfortunate results. I presume the resaon for conflating them is efficiency. Sorry, a Cmy crept into my code I was using for testing. So, it appears at least lexical globals are fixed in blead, although non-lexicals are still as broken as before. Ticket re-opened.