-
Notifications
You must be signed in to change notification settings - Fork 571
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
'my' declaration and ternary conditional op: unexpected behavior #16883
Comments
From dunedimensia@gmail.comCreated by dunedimensia@gmail.comHello. It seems that 'my' access both branches of ternary conditional operator(?). Also 'my' fails to compile ternary op. to declare one of the variables which are in branches. It tries to declare a condition. And 'local' do as expected. Same behavior in version 5.28.0 #!/usr/bin/perl -wl use strict; my( $A, $B ) = ( 5, 7 ); for my $i ( 0 .. 1 ){ print "[$A],[$B]"; __END__ Perl Info
|
From @GrinnzThis is intended behavior. "my" has a compile time behavior of declaring the variable in the current lexical scope, which will mask the variable from outside the scope regardless of the ternary. Assignment and "local" occur at runtime, as "local" is dynamically scoped. -Dan |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#133918 (status was 'open')
Searchable as RT133918$
The text was updated successfully, but these errors were encountered: