Skip to content

Commit a2cbfa4

Browse files
committed
Some more void context cleanups.
1 parent 00bb439 commit a2cbfa4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/QAST/Compiler.nqp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ class QAST::Compiler is HLL::Compiler {
369369
my @*INNERS := @inners;
370370
my $*HAVE_IMM_ARG := 0;
371371
my $*QAST_BLOCK_NO_CLOSE := 0;
372+
my $*WANT;
372373
my $err;
373374
try {
374375
$stmts := self.compile_all_the_stmts($node.list);
@@ -588,6 +589,7 @@ class QAST::Compiler is HLL::Compiler {
588589
{
589590
my $*BLOCK := $block;
590591
my $*HLL := 'nqp';
592+
my $*WANT;
591593
$stmts := self.compile_all_the_stmts($node.list);
592594
}
593595

@@ -633,10 +635,14 @@ class QAST::Compiler is HLL::Compiler {
633635
my $last;
634636
my $ops := PIRT::Ops.new();
635637
$ops.node($node) if $node;
636-
my $i := 0;
637-
my $n := +@stmts;
638+
my int $i := 0;
639+
my int $n := +@stmts;
640+
my $all_void := $*WANT eq 'v';
641+
unless nqp::defined($resultchild) {
642+
$resultchild := $n - 1;
643+
}
638644
for @stmts {
639-
my $void := $i + 1 < $n;
645+
my $void := $all_void || $i != $resultchild;
640646
if $void {
641647
if nqp::istype($_, QAST::Want) {
642648
$_ := want($_, 'v');
@@ -648,14 +654,11 @@ class QAST::Compiler is HLL::Compiler {
648654
}
649655
$ops.push($last)
650656
unless $void && nqp::istype($_, QAST::Var);
651-
if nqp::defined($resultchild) && $resultchild == $i {
657+
if $resultchild == $i {
652658
$ops.result($last.result);
653659
}
654660
$i := $i + 1;
655661
}
656-
if $last && !nqp::defined($resultchild) {
657-
$ops.result($last.result);
658-
}
659662
$ops
660663
}
661664

0 commit comments

Comments
 (0)