File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -363,12 +363,14 @@ for <while until> -> $op_name {
363
363
# Compile each of the children; we'll need to look at the result
364
364
# types and pick an overall result type if in non-void context.
365
365
my @ comp_ops ;
366
+ my @ comp_types ;
366
367
for $ op . list {
367
368
my $ comp := $ qastcomp . as_post($ _ );
368
369
@ comp_ops . push ($ comp );
370
+ @ comp_types . push ($ qastcomp . infer_type($ comp ));
369
371
}
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" ();
372
374
373
375
# Evaluate the condition; store result if needed.
374
376
my $ ops := $ qastcomp . post_new(' Ops' );
@@ -414,12 +416,14 @@ for <repeat_while repeat_until> -> $op_name {
414
416
# Compile each of the children; we'll need to look at the result
415
417
# types and pick an overall result type if in non-void context.
416
418
my @ comp_ops ;
419
+ my @ comp_types ;
417
420
for $ op . list {
418
421
my $ comp := $ qastcomp . as_post($ _ );
419
422
@ comp_ops . push ($ comp );
423
+ @ comp_types . push ($ qastcomp . infer_type($ comp ));
420
424
}
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" ();
423
427
424
428
# Evaluate the condition; store result if needed.
425
429
my $ ops := $ qastcomp . post_new(' Ops' );
You can’t perform that action at this time.
0 commit comments