According to S02, this is the right behavior. "Any remaining special variables will be lexically scoped. This includes C<$_> [...]"
On Fri, Jun 25, 2010 at 1:34 AM, Stéphane Payrard <cognomi...@gmail.com> wrote: > Seeing the generated code for > > for 1 -> $a { } > > The code concerning $_ seems spurious because there is an explicit parameter > $a. > It seems that a unneeded call to add_implicit_var is made in > Actions.pm that causes this > code to be generated. > Will track further tomorrow if jonathan++ does not beat me to it. > > > find_lex_skip_current $P72, "$/" > $P73 = new ['Perl6Scalar'], $P72 > setprop $P73, "rw", true > .lex "$/", $P73 > find_lex_skip_current $P74, "$!" > $P75 = new ['Perl6Scalar'], $P74 > setprop $P75, "rw", true > .lex "$!", $P75 > .lex "call_sig", param_76 > new $P77, "Perl6Scalar" > .lex "$a", $P77 > > > On Thu, Jun 24, 2010 at 11:55 PM, perl6 via RT > <perl6-bugs-follo...@perl.org> wrote: >> Greetings, >> >> This message has been automatically generated in response to the >> creation of a trouble ticket regarding: >> "Re: [BUG] $_ as a lhs not handled correctly in a given/when", >> a summary of which appears below. >> >> There is no need to reply to this message right now. Your ticket has been >> assigned an ID of [perl #76068]. >> >> Please include the string: >> >> [perl #76068] >> >> in the subject line of all future correspondence about this issue. To do so, >> you may reply to this message. >> >> Thank you, >> perl6-bugs-follo...@perl.org >> >> ------------------------------------------------------------------------- >> The bug is unrelated to the when construct but is related to the >> handling of iterations. >> The following lines has the same wrong behaviour as the previous one. >> >> $_=1; for 11..12 -> $a { if $_ == 1 { say "1 : $_"; $_=2 } else { >> say "* : $_ "} } >> >> On Thu, Jun 24, 2010 at 10:33 PM, Stéphane Payrard <cognomi...@gmail.com> >> wrote: >>> $_=1; for 11..12 -> $a { when 1 { say "1 : $_"; $_=2 } when * { say >>> "* : $_ " } } >>> >>> output is "1 : 1\n1 : 1" instead of the expected "1 : 1\n* : 2". >>> >>> The example is golfed and artificial. But there can be legitimate >>> purposes iterating, >>> modifying $_ in a branch and branching accordingly in the next iteration, >>> with the loop iterator not stored in $_. >>> >>> -- >>> cognominal stef >>> >> >> >> >> -- >> cognominal stef >> >> > > > > -- > cognominal stef > -- cognominal stef