Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not return the previous value when generator function of sequence …
…calls 'last'

fixes things like 'say 10,9,8, { diff - 1 || last } ... *'
  • Loading branch information
usev6 committed Mar 23, 2015
1 parent af6bd02 commit bc08619
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/core/operators.pm
Expand Up @@ -187,6 +187,7 @@ sub SEQUENCE($left, Mu $right, :$exclude_end) {
my $count = $code.count;
while 1 {
$tail.munch($tail.elems - $count);
$value := Nil; ## don't return previous value when 'last' is called from $code
$value := $code(|$tail);
if $end_code_arity != 0 {
$end_tail.push($value);
Expand Down

1 comment on commit bc08619

@usev6
Copy link
Contributor Author

@usev6 usev6 commented on bc08619 Mar 23, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example evaluation in the commit message contains a copy-and-pasto. Correct code:

say 10,9,8, { $_ - 1 || last } ... *

Please sign in to comment.