Skip to content

Commit b4a78bf

Browse files
committed
Fix various bits of bustage in loop construct code-gen.
1 parent 0099a4e commit b4a78bf

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/QAST/Operations.nqp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,14 @@ for <while until> -> $op_name {
363363
# Compile each of the children; we'll need to look at the result
364364
# types and pick an overall result type if in non-void context.
365365
my @comp_ops;
366+
my @comp_types;
366367
for $op.list {
367368
my $comp := $qastcomp.as_post($_);
368369
@comp_ops.push($comp);
370+
@comp_types.push($qastcomp.infer_type($comp));
369371
}
370-
my $res_type := 'i';
371-
my $res_reg := $*REGALLOC."fresh_$res_type"();
372+
my $res_type := @comp_types[0] eq @comp_types[1] ?? nqp::lc(@comp_types[0]) !! 'p';
373+
my $res_reg := $*REGALLOC."fresh_$res_type"();
372374

373375
# Evaluate the condition; store result if needed.
374376
my $ops := $qastcomp.post_new('Ops');
@@ -414,12 +416,14 @@ for <repeat_while repeat_until> -> $op_name {
414416
# Compile each of the children; we'll need to look at the result
415417
# types and pick an overall result type if in non-void context.
416418
my @comp_ops;
419+
my @comp_types;
417420
for $op.list {
418421
my $comp := $qastcomp.as_post($_);
419422
@comp_ops.push($comp);
423+
@comp_types.push($qastcomp.infer_type($comp));
420424
}
421-
my $res_type := 'i';
422-
my $res_reg := $*REGALLOC."fresh_$res_type"();
425+
my $res_type := @comp_types[0] eq @comp_types[1] ?? nqp::lc(@comp_types[0]) !! 'p';
426+
my $res_reg := $*REGALLOC."fresh_$res_type"();
423427

424428
# Evaluate the condition; store result if needed.
425429
my $ops := $qastcomp.post_new('Ops');

0 commit comments

Comments
 (0)