From 3cb8fc1499e9adec735cc3d114dd9976a17090a8 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Fri, 7 Jul 2023 14:50:32 +0200 Subject: [PATCH] Tweak printing of if/then/else --- compiler/shared_ast/print.ml | 3 ++- tests/test_array/good/aggregation_3.catala_en | 3 ++- tests/test_func/good/closure_conversion_reduce.catala_en | 8 ++++---- .../good/scope_call_func_struct_closure.catala_en | 3 +-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/shared_ast/print.ml b/compiler/shared_ast/print.ml index 53a2a634..7e235bd7 100644 --- a/compiler/shared_ast/print.ml +++ b/compiler/shared_ast/print.ml @@ -586,7 +586,8 @@ let rec expr_aux : | EIfThenElse _ -> let rec pr els fmt = function | EIfThenElse { cond; etrue; efalse }, _ -> - Format.fprintf fmt "@[%a@ %a@]@ @[%a@ %a@]@ %a" keyword + Format.fprintf fmt "@[@[%a@ %a@;<1 -2>%a@]@ %a@]@ %a" + keyword (if els then "else if" else "if") expr cond keyword "then" expr etrue (pr true) efalse | e -> Format.fprintf fmt "@[%a@ %a@]" keyword "else" (rhs exprc) e diff --git a/tests/test_array/good/aggregation_3.catala_en b/tests/test_array/good/aggregation_3.catala_en index 767d286d..25093b09 100644 --- a/tests/test_array/good/aggregation_3.catala_en +++ b/tests/test_array/good/aggregation_3.catala_en @@ -71,7 +71,8 @@ let scope S (x: integer|internal|output) = to_rat ((2 - i) * (2 - i))) < let i : integer = i_2 in to_rat ((2 - i) * (2 - i)) - then i_1 + then + i_1 else i_2) 42 [ 1; 2; 3 ]) diff --git a/tests/test_func/good/closure_conversion_reduce.catala_en b/tests/test_func/good/closure_conversion_reduce.catala_en index e22c8eec..d32c2898 100644 --- a/tests/test_func/good/closure_conversion_reduce.catala_en +++ b/tests/test_func/good/closure_conversion_reduce.catala_en @@ -34,8 +34,8 @@ let scope S | ESome y_0 → let potential_max_1 : integer = y_0 in let potential_max_2 : integer = y_3 in - if potential_max_1 < potential_max_2 - then ESome potential_max_1 + if potential_max_1 < potential_max_2 then + ESome potential_max_1 else ESome potential_max_2) ESome -1 y_2) @@ -83,8 +83,8 @@ let scope S | ESome y_0 → let potential_max_1 : integer = y_0 in let potential_max_2 : integer = y_3 in - if potential_max_1 < potential_max_2 - then ESome potential_max_1 + if potential_max_1 < potential_max_2 then + ESome potential_max_1 else ESome potential_max_2) ESome -1 y_2)) diff --git a/tests/test_func/good/scope_call_func_struct_closure.catala_en b/tests/test_func/good/scope_call_func_struct_closure.catala_en index d88c0f66..cefbbbf6 100644 --- a/tests/test_func/good/scope_call_func_struct_closure.catala_en +++ b/tests/test_func/good/scope_call_func_struct_closure.catala_en @@ -171,8 +171,7 @@ let scope Foo (match b with | ENone _ → ENone _ | ESome b → - if b - then + if b then match (match (SubFoo1 { SubFoo1_in x_in = ESome 10; }).x with | ENone _ → ENone _