Explorar o código

[cs] generate "else if" without extra blocks

Dan Korostelev %!s(int64=11) %!d(string=hai) anos
pai
achega
c0813e93f6
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      gencs.ml

+ 6 - 1
gencs.ml

@@ -1399,7 +1399,12 @@ let configure gen =
 						| Some e ->
 							write w "else ";
 							in_value := false;
-							expr_s w (mk_block e)
+							let e = match e.eexpr with
+								| TIf _ -> e
+								| TBlock [{eexpr = TIf _} as e] -> e
+								| _ -> mk_block e
+							in
+							expr_s w e
 					)
 				| TWhile (econd, eblock, flag) ->
 					(match flag with