@@ -4867,9 +4867,12 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48674867 match e2'o with
48684868 None -> (* has form "e1 ? : e3" *)
48694869 let tmp = var (newTempVar nil true tresult) in
4870- let (se1, _, _) = doExp asconst e1 (ASet (tmp, tresult)) in
4870+ let (se1, e1', t1) = doExp asconst e1 (AExp None ) in
4871+ let (se1, _, _) = finishExp ~new What:(ASet (tmp, tresult))
4872+ se1 (snd (castTo ~kind: ConditionalConversion t1 tresult e1')) tresult in
48714873 let (se3, _, _) = finishExp ~new What:(ASet (tmp, tresult))
4872- se3 e3' t3 in
4874+ se3 (snd (castTo ~kind: ConditionalConversion t3 tresult e3')) tresult in
4875+ (* TODO: technically, it might be more accurate to branch on the value of e1' before ConditionalConversion *)
48734876 finishExp (se1 @@ ifChunk (Lval (tmp)) ! currentLoc ! currentExpLoc
48744877 skipChunk se3)
48754878 (Lval (tmp))
@@ -4882,12 +4885,11 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
48824885 let tmp = newTempVar nil true tresult in
48834886 var tmp, tresult
48844887 in
4885- (* TODO: ConditionalConversion casts aren't inserted *)
48864888 (* Now add the stmts lv:=e2 and lv:=e3 to se2 and se3 *)
48874889 let (se2, _, _) = finishExp ~new What:(ASet (lv,lvt))
4888- se2 e2' t2 in
4890+ se2 (snd (castTo ~kind: ConditionalConversion t2 tresult e2')) tresult in
48894891 let (se3, _, _) = finishExp ~new What:(ASet (lv,lvt))
4890- se3 e3' t3 in
4892+ se3 (snd (castTo ~kind: ConditionalConversion t3 tresult e3')) tresult in
48914893 finishExp (doCondition asconst e1 se2 se3) (Lval (lv)) tresult
48924894 end
48934895
0 commit comments