mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Closure conversion: empty tuples are OK
it's much simpler to handle down the line if they have a uniform structure; empty tuples are easily converted into unit types when translating to OCaml.
This commit is contained in:
parent
676edef101
commit
dd3285bb66
@ -118,21 +118,17 @@ let build_closure :
|
||||
~op:(Operator.ToClosureEnv, pos)
|
||||
~tys:
|
||||
[
|
||||
( (if free_vars = [] then TLit TUnit
|
||||
else TTuple free_vars_types),
|
||||
( TTuple free_vars_types,
|
||||
pos );
|
||||
]
|
||||
~args:
|
||||
[
|
||||
(if free_vars = [] then
|
||||
Expr.elit LUnit (mark_ty (TLit TUnit, pos))
|
||||
else
|
||||
Expr.etuple
|
||||
(List.map
|
||||
(fun (extra_var, m) ->
|
||||
Bindlib.box_var extra_var, Expr.with_pos pos m)
|
||||
free_vars)
|
||||
(mark_ty (TTuple free_vars_types, pos)));
|
||||
Expr.etuple
|
||||
(List.map
|
||||
(fun (extra_var, m) ->
|
||||
Bindlib.box_var extra_var, Expr.with_pos pos m)
|
||||
free_vars)
|
||||
(mark_ty (TTuple free_vars_types, pos));
|
||||
]
|
||||
(mark_ty (TClosureEnv, pos));
|
||||
])
|
||||
|
@ -219,6 +219,7 @@ let rec format_typ (fmt : Format.formatter) (typ : typ) : unit =
|
||||
in
|
||||
match Mark.remove typ with
|
||||
| TLit l -> Format.fprintf fmt "%a" Print.tlit l
|
||||
| TTuple [] -> Format.fprintf fmt "unit"
|
||||
| TTuple ts ->
|
||||
Format.fprintf fmt "@[<hov 2>(%a)@]"
|
||||
(Format.pp_print_list
|
||||
|
Loading…
Reference in New Issue
Block a user