Skip to content

Commit f5d0884

Browse files
committed
Don't emit variable lookup code when the variable is in void context. Cuts down on code generated for declarations, but also fixes implicit %_ handling.
1 parent c21542a commit f5d0884

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/QAST/Compiler.nqp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,13 @@ class QAST::Compiler is HLL::Compiler {
529529
my $i := 0;
530530
my $n := +@stmts;
531531
for @stmts {
532-
if nqp::istype($_, QAST::Want) && $i + 1 < $n {
532+
my $void := $i + 1 < $n;
533+
if nqp::istype($_, QAST::Want) && $void {
533534
$_ := want($_, 'v');
534535
}
535536
$last := self.as_post($_);
536-
$ops.push($last);
537+
$ops.push($last)
538+
unless $void && nqp::istype($_, QAST::Var);
537539
if nqp::defined($resultchild) && $resultchild == $i {
538540
$ops.result($last.result);
539541
}

0 commit comments

Comments
 (0)