@@ -940,18 +940,17 @@ for ('', 'repeat_') -> $repness {
940
940
QAST ::Var. new ( : name($ cond_temp ), : scope(' local' ) ));
941
941
}
942
942
943
- # Compile each of the children; we'll need to look at the result
944
- # types and pick an overall result type if in non-void context.
943
+ # Compile each of the children.
945
944
my @ comp_ops ;
946
945
my @ comp_types ;
947
946
for @ children {
948
- my $ comp := $ qastcomp . as_mast($ _ );
947
+ my $ comp := nqp :: elems (@ comp_ops ) == 0
948
+ ?? $ qastcomp . as_mast($ _ )
949
+ !! $ qastcomp . as_mast($ _ , : want($ MVM_reg_void ));
949
950
@ comp_ops . push ($ comp );
950
951
@ comp_types . push ($ comp . result_kind);
951
952
}
952
- my $ res_kind := @ comp_types [0 ] == @ comp_types [1 ]
953
- ?? @ comp_types [0 ]
954
- !! $ MVM_reg_obj ;
953
+ my $ res_kind := @ comp_types [0 ];
955
954
my $ res_reg := $ * REGALLOC . fresh_register($ res_kind );
956
955
957
956
# Check operand count.
@@ -962,7 +961,6 @@ for ('', 'repeat_') -> $repness {
962
961
# Test the condition and jump to the loop end if it's
963
962
# not met.
964
963
my @ loop_il ;
965
- my $ coerced := $ qastcomp . coerce(@ comp_ops [0 ], $ res_kind );
966
964
if $ repness {
967
965
# It's a repeat_ variant, need to go straight into the
968
966
# loop body unconditionally. Be sure to set the register
@@ -984,8 +982,8 @@ for ('', 'repeat_') -> $repness {
984
982
push_op(@ loop_il , ' goto' , $ redo_lbl );
985
983
}
986
984
nqp :: push (@ loop_il , $ test_lbl );
987
- push_ilist(@ loop_il , $ coerced );
988
- push_op(@ loop_il , ' set' , $ res_reg , $ coerced . result_reg);
985
+ push_ilist(@ loop_il , @ comp_ops [ 0 ] );
986
+ push_op(@ loop_il , ' set' , $ res_reg , @ comp_ops [ 0 ] . result_reg);
989
987
if @ comp_ops [0 ]. result_kind == $ MVM_reg_obj {
990
988
push_op(@ loop_il , ' decont' , @ comp_ops [0 ]. result_reg, @ comp_ops [0 ]. result_reg);
991
989
}
@@ -1004,7 +1002,6 @@ for ('', 'repeat_') -> $repness {
1004
1002
my $ body := $ qastcomp . coerce(@ comp_ops [1 ], $ res_kind );
1005
1003
nqp :: push (@ loop_il , $ redo_lbl );
1006
1004
push_ilist(@ loop_il , $ body );
1007
- push_op(@ loop_il , ' set' , $ res_reg , $ body . result_reg);
1008
1005
1009
1006
# If there's a third child, evaluate it as part of the
1010
1007
# "next".
0 commit comments