mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
style
This commit is contained in:
parent
8553b9dd7e
commit
9f31715a47
@ -29,9 +29,9 @@ let rule ctx env rule =
|
||||
let env =
|
||||
match rule.rule_parameter with
|
||||
| None -> env
|
||||
| Some l ->
|
||||
let vs, tys = List.split l in
|
||||
ListLabels.fold_right2 vs tys ~init:env ~f:Typing.Env.add_var
|
||||
| Some vars_and_types ->
|
||||
ListLabels.fold_right vars_and_types ~init:env ~f:(fun (v, t) ->
|
||||
Typing.Env.add_var v t)
|
||||
in
|
||||
(* Note: we could use the known rule type here to direct typing. We choose not
|
||||
to because it shouldn't be needed for disambiguation, and we prefer to
|
||||
|
@ -1205,8 +1205,9 @@ let process_topdef
|
||||
(Marked.get_mark def.S.topdef_name)
|
||||
in
|
||||
let typ =
|
||||
if List.length arg_types = 0 then body_type
|
||||
else TArrow (arg_types, body_type), ty_pos
|
||||
match arg_types with
|
||||
| [] -> body_type
|
||||
| _ -> TArrow (arg_types, body_type), ty_pos
|
||||
in
|
||||
{
|
||||
prgm with
|
||||
|
@ -727,8 +727,7 @@ let make_app e args pos =
|
||||
| fty :: argtys -> (
|
||||
match Marked.unmark fty.ty with
|
||||
| TArrow (tx', tr) ->
|
||||
assert (
|
||||
argtys |> List.map (fun x -> x.ty) |> Type.unifiable_list tx');
|
||||
assert (Type.unifiable_list tx' (List.map (fun x -> x.ty) argtys));
|
||||
tr
|
||||
| TAny -> fty.ty
|
||||
| _ -> assert false))
|
||||
|
@ -155,13 +155,13 @@ let rec unify
|
||||
let () =
|
||||
match Marked.unmark t1_repr, Marked.unmark t2_repr with
|
||||
| TLit tl1, TLit tl2 -> if tl1 <> tl2 then raise_type_error ()
|
||||
| TArrow (t11, t12), TArrow (t21, t22) ->
|
||||
| TArrow (t11, t12), TArrow (t21, t22) -> (
|
||||
unify e t12 t22;
|
||||
if List.length t11 = List.length t21 then List.iter2 (unify e) t11 t21
|
||||
else raise_type_error ()
|
||||
| TTuple ts1, TTuple ts2 ->
|
||||
if List.length ts1 = List.length ts2 then List.iter2 (unify e) ts1 ts2
|
||||
else raise_type_error ()
|
||||
try List.iter2 (unify e) t11 t21
|
||||
with Invalid_argument _ -> raise_type_error ())
|
||||
| TTuple ts1, TTuple ts2 -> (
|
||||
try List.iter2 (unify e) ts1 ts2
|
||||
with Invalid_argument _ -> raise_type_error ())
|
||||
| TStruct s1, TStruct s2 ->
|
||||
if not (A.StructName.equal s1 s2) then raise_type_error ()
|
||||
| TEnum e1, TEnum e2 ->
|
||||
|
@ -48,12 +48,12 @@ If a compiler change causes a lot of regressions (error message formatting chang
|
||||
for instance), you can mass-reset the expected outputs with
|
||||
`make test_suite CLERK_OPTS=--reset`.
|
||||
`git diff` will then allow to check all the changes at once.
|
||||
**Caution**: It's your responsibility to check all the changes before committing them.
|
||||
**Caution**: It's your responsability to check all the changes before committing them.
|
||||
|
||||
## Tips
|
||||
|
||||
* Running a single test-file just to check changes when tweaking either the compiler or the test file itself, but without updating or diffing with the reference can be useful when debugging. The following command outputs the result to `stdout` and can be used from within text editors:
|
||||
|
||||
clerk runtest test-file.catala_en
|
||||
# Or, to use the current build artifacts, wrap with `dune exec`:
|
||||
# Or, to use the current build artefacts, wrap with `dune exec`:
|
||||
dune exec --display=quiet --no-build -- clerk runtest -e dune -c "exec --display=quiet --no-build -- catala" test-file.catala_en
|
||||
|
Loading…
Reference in New Issue
Block a user