mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Restore full expression printing when --debug is set
This commit is contained in:
parent
89e90271c1
commit
98f712365e
@ -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 =
|
||||
|
@ -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
|
||||
|
@ -553,7 +553,8 @@ module Commands = struct
|
||||
List.iter
|
||||
(fun ((var, _), result) ->
|
||||
Message.emit_result "@[<hov 2>%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,6 +862,8 @@ let main () =
|
||||
in
|
||||
List.iter
|
||||
(fun 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
|
||||
|
@ -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 %
|
||||
|
@ -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: <function>
|
||||
[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 = <function>
|
||||
[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
|
||||
```
|
||||
|
@ -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 = <function>
|
||||
[RESULT] f2 = <function>
|
||||
[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 <function>
|
||||
[RESULT] f2 = ESome <function>
|
||||
[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)
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user