New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(if|unless) ( local ... ) not undone #4370
Comments
From bwarnock@capita.comLocal variables declared in a conditional expression of a $a = 10; Applies to local variables declared in 'if (expr)', 'unless(expr)', Occurs in 5.005_03 through 5.7.2. Flags: Site configuration information for perl v5.6.1: Configured by bryan at Sat Jun 9 11:24:22 EDT 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Locally applied patches: @INC for perl v5.6.1: Environment for perl v5.6.1: PATH=.:/home/bryan/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/sbin:/us |
From @smpeters
This behavior has been fixed in bleadperl by not allowing it.
|
@smpeters - Status changed from 'open' to 'resolved' |
From @tamiasOn Fri, Aug 26, 2005 at 09:06:50AM -0700, Steve Peters via RT wrote:
$a isn't a lexical variable in the example, so that doesn't fix it. Ronald |
From mjtg@cam.ac.ukSteve Peters wrote
No it hasn't. I suspect you did the wrong test - what's that When I try perl5.8.6 -w the bug is still present. I presume this is another manifestation of the fact that a conditional I presume the resaon for conflating them is efficiency. Mike Guy |
@smpeters - Status changed from 'resolved' to 'open' |
From @smpeters
Sorry, a C<my> crept into my code I was using for testing. So, it |
@smpeters - Status changed from 'open' to 'resolved' |
@smpeters - Status changed from 'resolved' to 'open' |
From @schwernOn Fri, Aug 26, 2005 at 09:06:50AM -0700, Steve Peters via RT wrote:
Still busted in 5.8.6 and blead. $ bleadperl -wle '$a = 10; if( local $a = 1 ) {} print $a' -- |
From @jkeenanOn Sat Sep 10 14:08:31 2005, schwern wrote:
And still busted in 5.16.0. |
From @iabynOn Sat, May 26, 2012 at 06:10:39PM -0700, James E Keenan via RT wrote:
The comparison to lexical vars is slightly misleading; its actually sub DESTROY { warn "DESTROY(@_)\n" } { warn "----\n"; { if (local $a = 2) { which outputs: in IF block: main=ARRAY(0x235bde8) Here, the scope of when the lexical is freed and when the 'local' is -- |
From @doyOn Sun, May 27, 2012 at 11:22:45PM +0100, Dave Mitchell wrote:
I've run into this several times in my own code, in the form of: if (my $foo = something()) { which gives a '"my" variable $foo masks earlier declaration in same scope' -doy |
This ticket was erroneously migrated in a closed state |
I'm not convinced doy's thing is actually the same problem - the contents of the psuedoscope for the if condition should persist further on, given e.g.
being perfectly reasonable code - the question of whether the elsif condition should regard itself as a direct continuation of the if condition's pseudoscope (in which case the warning is correct) or as a new pseudoscope deriving itself from the if condition's pseudoscope (in which case the code doy provides should be warning free) seems arguable either way but separate to the late-destroy problem AFAICT. |
I believe the current behavior is the correct one in the bigger picture, even if I understand why the behavior proposed here is more intuitive at first |
Migrated from rt.perl.org#7615 (status was 'open')
Searchable as RT7615$
The text was updated successfully, but these errors were encountered: