diff --git a/build_system/clerk_driver.ml b/build_system/clerk_driver.ml index a7d4687f..da5d1cb0 100644 --- a/build_system/clerk_driver.ml +++ b/build_system/clerk_driver.ml @@ -635,6 +635,7 @@ let run_inline_tests not (String.starts_with ~prefix:"OCAMLRUNPARAM=" s)) |> Seq.cons "CATALA_OUT=-" |> Seq.cons "CATALA_COLOR=never" + |> Seq.cons "CATALA_PLUGINS=" |> Array.of_seq in let pid = diff --git a/compiler/catala_utils/cli.ml b/compiler/catala_utils/cli.ml index 79496f24..dc572894 100644 --- a/compiler/catala_utils/cli.ml +++ b/compiler/catala_utils/cli.ml @@ -183,7 +183,7 @@ module Flags = struct "_build" / "default" / "compiler" / "plugins"; ] in - value & opt_all dir default & info ["plugin-dir"] ~docv:"DIR" ~env ~doc + value & opt_all string default & info ["plugin-dir"] ~docv:"DIR" ~env ~doc let disable_warnings = value diff --git a/compiler/driver.ml b/compiler/driver.ml index 9206449f..16a17031 100644 --- a/compiler/driver.ml +++ b/compiler/driver.ml @@ -553,7 +553,8 @@ module Commands = struct List.iter (fun ((var, _), result) -> Message.emit_result "@[%s@ =@ %a@]" var - (Print.UserFacing.value (get_lang options options.input_file)) + (if options.Cli.debug then Print.expr ~debug:false () + else Print.UserFacing.value (get_lang options options.input_file)) result) results @@ -861,11 +862,13 @@ let main () = in List.iter (fun d -> - match Sys.is_directory d with - | true -> Plugin.load_dir d - | false -> Message.emit_debug "Could not read plugin directory %s" d - | exception Sys_error _ -> - Message.emit_debug "Could not read plugin directory %s" d) + if d = "" then () + else + match Sys.is_directory d with + | true -> Plugin.load_dir d + | false -> Message.emit_debug "Could not read plugin directory %s" d + | exception Sys_error _ -> + Message.emit_debug "Could not read plugin directory %s" d) plugins_dirs; Dynlink.allow_only ["Runtime_ocaml__Runtime"]; (* We may use dynlink again, but only for runtime modules: no plugin diff --git a/compiler/shared_ast/print.ml b/compiler/shared_ast/print.ml index e9532cf1..53a2a634 100644 --- a/compiler/shared_ast/print.ml +++ b/compiler/shared_ast/print.ml @@ -954,7 +954,8 @@ module UserFacing = struct if Z.equal n Z.zero then 0 else 1 + ndigits (Z.div n (Z.of_int 10)) in aux 0 - (if Z.equal int_part Z.zero then None else Some (Cli.globals.max_prec_digits - ndigits int_part)) + (if Z.equal int_part Z.zero then None + else Some (Cli.globals.max_prec_digits - ndigits int_part)) rem (* It would be nice to print ratios as % but that's impossible to guess. Trying would lead to inconsistencies where some comparable numbers are in % diff --git a/tests/test_scope/good/scope_call3.catala_en b/tests/test_scope/good/scope_call3.catala_en index 425ec40b..814a1a48 100644 --- a/tests/test_scope/good/scope_call3.catala_en +++ b/tests/test_scope/good/scope_call3.catala_en @@ -17,7 +17,18 @@ scope RentComputation: ``` ```catala-test-inline -$ catala Interpret -t -s HousingComputation +$ catala Interpret -t -s HousingComputation --debug +[DEBUG] Collecting rules... +[DEBUG] Reading files... +[DEBUG] Parsing tests/test_scope/good/scope_call3.catala_en +[DEBUG] Name resolution... +[DEBUG] Desugaring... +[DEBUG] Disambiguating... +[DEBUG] Linting... +[DEBUG] Typechecking... +[DEBUG] Translating to default calculus... +[DEBUG] Typechecking again... +[DEBUG] Starting interpretation... [LOG] ≔ HousingComputation.f: [LOG] ☛ Definition applied: ┌─⯈ tests/test_scope/good/scope_call3.catala_en:8.14-8.20: @@ -68,7 +79,30 @@ $ catala Interpret -t -s HousingComputation [LOG] ≔ HousingComputation.f.output: 3 [LOG] ← HousingComputation.f [LOG] ≔ HousingComputation.result: 3 +[DEBUG] End of interpretation [RESULT] Computation successful! Results: -[RESULT] f = +[RESULT] +f = λ (x: integer) → + error_empty + ⟨true + ⊢ (let result : RentComputation = + (λ (RentComputation_in: RentComputation_in) → + let g : integer → integer = + λ (x1: integer) → + error_empty ⟨true ⊢ x1 + 1⟩ + in + let f : integer → integer = + λ (x1: integer) → + error_empty ⟨true ⊢ g (x1 + 1)⟩ + in + { RentComputation f = f; }) + {RentComputation_in} + in + let result1 : RentComputation = + { RentComputation f = λ (param0: integer) → result.f param0; } + in + if true then result1 else result1). + f + x⟩ [RESULT] result = 3 ``` diff --git a/tests/test_scope/good/scope_call4.catala_en b/tests/test_scope/good/scope_call4.catala_en index 3dd36ae2..64e11950 100644 --- a/tests/test_scope/good/scope_call4.catala_en +++ b/tests/test_scope/good/scope_call4.catala_en @@ -23,15 +23,70 @@ scope RentComputation: ```catala-test-inline -$ catala Interpret -s RentComputation +$ catala Interpret -s RentComputation --debug +[DEBUG] Collecting rules... +[DEBUG] Reading files... +[DEBUG] Parsing tests/test_scope/good/scope_call4.catala_en +[DEBUG] Name resolution... +[DEBUG] Desugaring... +[DEBUG] Disambiguating... +[DEBUG] Linting... +[DEBUG] Typechecking... +[DEBUG] Translating to default calculus... +[DEBUG] Typechecking again... +[DEBUG] Starting interpretation... +[DEBUG] End of interpretation [RESULT] Computation successful! Results: -[RESULT] f1 = -[RESULT] f2 = +[RESULT] +f1 = λ (x: integer) → + error_empty ⟨true ⊢ let x1 : integer = x + 1 in + error_empty ⟨true ⊢ x1 + 1⟩⟩ +[RESULT] +f2 = λ (x: integer) → + error_empty ⟨true ⊢ let x1 : integer = x + 1 in + error_empty ⟨true ⊢ x1 + 1⟩⟩ ``` ```catala-test-inline -$ catala Interpret_Lcalc -s RentComputation --avoid_exceptions --optimize +$ catala Interpret_Lcalc -s RentComputation --avoid_exceptions --optimize --debug +[DEBUG] Collecting rules... +[DEBUG] Reading files... +[DEBUG] Parsing tests/test_scope/good/scope_call4.catala_en +[DEBUG] Name resolution... +[DEBUG] Desugaring... +[DEBUG] Disambiguating... +[DEBUG] Linting... +[DEBUG] Typechecking... +[DEBUG] Translating to default calculus... +[DEBUG] Optimizing default calculus... +[DEBUG] Typechecking again... +[DEBUG] Compiling program into lambda calculus... +[DEBUG] Optimizing lambda calculus... +[DEBUG] Starting interpretation... +[DEBUG] End of interpretation [RESULT] Computation successful! Results: -[RESULT] f1 = ESome -[RESULT] f2 = ESome +[RESULT] +f1 = + ESome + (λ (x: integer) → + ESome + match + (match (ESome (λ (x1: integer) → ESome (x1 + 1))) with + | ENone _ → ENone _ + | ESome g → g (x + 1)) + with + | ENone _ → raise NoValueProvided + | ESome f1 → f1) +[RESULT] +f2 = + ESome + (λ (x: integer) → + ESome + match + (match (ESome (λ (x1: integer) → ESome (x1 + 1))) with + | ENone _ → ENone _ + | ESome g → g (x + 1)) + with + | ENone _ → raise NoValueProvided + | ESome f2 → f2) ```