mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Fix a few remaining renaming glitches
This commit is contained in:
parent
cb88cb07a1
commit
634de675a2
@ -1,6 +1,18 @@
|
||||
# Reformatting commits to be skipped when running 'git blame'
|
||||
# Use `git config --global blame.ignoreRevsFile .git-blame-ignore-revs` to use it
|
||||
# Add new reformatting commits at the top
|
||||
6a062921f15c5b70e42fefee0f28d249d4289e34
|
||||
5d61963a93a0b735d9419b43ef05c676f5169d9a
|
||||
1b6da0b5720e9168aca1452e9ed40ad7e0bd737a
|
||||
840530163284da2d664f8e3e8a1ff89830132a1d
|
||||
dc1b725e9b9d34db3bef5da28c20a4e489b304d9
|
||||
79e0dcecdaa9ae129330ba371b627d6842d48dbc
|
||||
75bf76826486a96c0b4110a6758a561781d49145
|
||||
619cafebb8028ea9cc3bd49ed9334c9c39a1e6d3
|
||||
1ae955b50443edb123de4b612bc8c85935567c59
|
||||
d4198f52b47670a0ace3f65fed91ea28543a3488
|
||||
cf89204a4b0dcdc37554b9206bdc03c9a0d21fa8
|
||||
c4715ea86efa12cfdfd5b230c48f32a2cdb9552d
|
||||
|
||||
2708fa53b23bde545e7378a660cdb99e8671f1de
|
||||
a79acd1fa8b701a5688c7fa985c7064cd6d81acf
|
||||
|
@ -36,6 +36,10 @@ authors:
|
||||
family-names: Banuls
|
||||
- given-name: Aminata
|
||||
family-names: Boiguillé
|
||||
- given-name: Vincent
|
||||
family-names: Botbol
|
||||
affiliation: "INRIA"
|
||||
email: vincent.botbol@inria.fr
|
||||
repository-code: "https://github.com/CatalaLang/catala"
|
||||
url: "https://catala-lang.org/"
|
||||
abstract: >-
|
||||
@ -43,5 +47,5 @@ abstract: >-
|
||||
faithful-by-construction algorithms from
|
||||
legislative texts.
|
||||
license: Apache-2.0
|
||||
version: 0.8.0
|
||||
version: 0.10.0
|
||||
date-released: "2022-03-08"
|
||||
|
@ -134,8 +134,8 @@ let renaming =
|
||||
Renaming.program ()
|
||||
~reserved:ocaml_keywords
|
||||
(* TODO: add catala runtime built-ins as reserved as well ? *)
|
||||
~reset_context_for_closed_terms:true ~skip_constant_binders:true
|
||||
~constant_binder_name:(Some "_") ~namespaced_fields_constrs:true
|
||||
~skip_constant_binders:true ~constant_binder_name:(Some "_")
|
||||
~namespaced_fields_constrs:true
|
||||
|
||||
let format_struct_name (fmt : Format.formatter) (v : StructName.t) : unit =
|
||||
(match StructName.path v with
|
||||
|
@ -625,7 +625,6 @@ let program_to_graph
|
||||
{
|
||||
Renaming.reserved = [];
|
||||
sanitize_varname = String.to_snake_case;
|
||||
reset_context_for_closed_terms = false;
|
||||
skip_constant_binders = false;
|
||||
constant_binder_name = None;
|
||||
})
|
||||
|
@ -209,6 +209,7 @@ and translate_expr (ctxt : 'm ctxt) (expr : 'm L.expr) :
|
||||
let exceptions_stmts, new_exceptions, ren_ctx =
|
||||
translate_expr_list ctxt exceptions
|
||||
in
|
||||
let ctxt = { ctxt with ren_ctx } in
|
||||
let eposl, vposdefs, ctxt =
|
||||
List.fold_left
|
||||
(fun (eposl, vposdefs, ctxt) exc ->
|
||||
@ -225,11 +226,9 @@ and translate_expr (ctxt : 'm ctxt) (expr : 'm L.expr) :
|
||||
ctxt )
|
||||
else
|
||||
let arr_var_name, ctxt =
|
||||
fresh_var ~pos { ctxt with ren_ctx } ctxt.context_name
|
||||
in
|
||||
let pos_arr_var_name, ctxt =
|
||||
fresh_var ~pos { ctxt with ren_ctx } "pos_list"
|
||||
fresh_var ~pos ctxt ("exc_" ^ ctxt.context_name)
|
||||
in
|
||||
let pos_arr_var_name, ctxt = fresh_var ~pos ctxt "pos_list" in
|
||||
let stmts =
|
||||
stmts
|
||||
++ RevBlock.make
|
||||
@ -475,7 +474,7 @@ and translate_statements (ctxt : 'm ctxt) (block_expr : 'm L.expr) :
|
||||
{ ctxt with inside_definition_of = None }
|
||||
vars_tau
|
||||
in
|
||||
let new_body, _ren_ctx = translate_statements ctxt body in
|
||||
let new_body, ren_ctx = translate_statements ctxt body in
|
||||
( [
|
||||
( A.SInnerFuncDef
|
||||
{
|
||||
@ -497,10 +496,9 @@ and translate_statements (ctxt : 'm ctxt) (block_expr : 'm L.expr) :
|
||||
},
|
||||
binder_pos );
|
||||
],
|
||||
ctxt.ren_ctx )
|
||||
ren_ctx )
|
||||
| EMatch { e = e1; cases; name } ->
|
||||
let typ = Expr.maybe_ty (Mark.get e1) in
|
||||
let pos = Expr.pos block_expr in
|
||||
let e1_stmts, new_e1, ren_ctx = translate_expr ctxt e1 in
|
||||
let ctxt = { ctxt with ren_ctx } in
|
||||
let e1_stmts, switch_var, ctxt =
|
||||
@ -514,63 +512,45 @@ and translate_statements (ctxt : 'm ctxt) (block_expr : 'm L.expr) :
|
||||
v,
|
||||
ctxt )
|
||||
in
|
||||
let new_cases =
|
||||
let new_cases, ren_ctx =
|
||||
EnumConstructor.Map.fold
|
||||
(fun _ arg new_args ->
|
||||
(fun _ arg (new_args, ren_ctx) ->
|
||||
match Mark.remove arg with
|
||||
| EAbs { binder; tys = typ :: _ } ->
|
||||
let vars, body, ctxt = unmbind ctxt binder in
|
||||
let vars, body, ctxt = unmbind { ctxt with ren_ctx } binder in
|
||||
assert (Array.length vars = 1);
|
||||
let var = vars.(0) in
|
||||
let scalc_var, ctxt =
|
||||
register_fresh_var ctxt var ~pos:(Expr.pos arg)
|
||||
in
|
||||
let new_arg, _ren_ctx = translate_statements ctxt body in
|
||||
{
|
||||
A.case_block = new_arg;
|
||||
payload_var_name = scalc_var;
|
||||
payload_var_typ = typ;
|
||||
}
|
||||
:: new_args
|
||||
( {
|
||||
A.case_block = new_arg;
|
||||
payload_var_name = scalc_var;
|
||||
payload_var_typ = typ;
|
||||
}
|
||||
:: new_args,
|
||||
ctxt.ren_ctx )
|
||||
| _ -> assert false)
|
||||
cases []
|
||||
cases ([], ctxt.ren_ctx)
|
||||
in
|
||||
let new_args = List.rev new_cases in
|
||||
let ctxt = { ctxt with ren_ctx } in
|
||||
let tail =
|
||||
if ctxt.config.keep_special_ops then
|
||||
let tmp_var = A.VarName.fresh ("match_arg", pos) in
|
||||
[
|
||||
( A.SLocalInit
|
||||
{
|
||||
name = tmp_var, pos;
|
||||
typ = Expr.maybe_ty (Mark.get e1);
|
||||
expr = new_e1;
|
||||
},
|
||||
pos );
|
||||
( A.SSwitch
|
||||
{
|
||||
switch_var = tmp_var;
|
||||
switch_var_typ = typ;
|
||||
enum_name = name;
|
||||
switch_cases = new_args;
|
||||
},
|
||||
pos );
|
||||
]
|
||||
else
|
||||
[
|
||||
( A.SSwitch
|
||||
{
|
||||
switch_var;
|
||||
switch_var_typ = typ;
|
||||
enum_name = name;
|
||||
switch_cases = List.rev new_cases;
|
||||
},
|
||||
Expr.pos block_expr );
|
||||
]
|
||||
[
|
||||
( A.SSwitch
|
||||
{
|
||||
switch_var;
|
||||
switch_var_typ = typ;
|
||||
enum_name = name;
|
||||
switch_cases = List.rev new_cases;
|
||||
},
|
||||
Expr.pos block_expr );
|
||||
]
|
||||
in
|
||||
RevBlock.rebuild e1_stmts ~tail, ren_ctx
|
||||
RevBlock.rebuild e1_stmts ~tail, ctxt.ren_ctx
|
||||
| EIfThenElse { cond; etrue; efalse } ->
|
||||
let cond_stmts, s_cond, ren_ctx = translate_expr ctxt cond in
|
||||
let ctxt = { ctxt with ren_ctx } in
|
||||
let s_e_true, _ = translate_statements ctxt etrue in
|
||||
let s_e_false, _ = translate_statements ctxt efalse in
|
||||
( RevBlock.rebuild cond_stmts
|
||||
@ -808,20 +788,25 @@ let translate_program ~(config : translation_config) (p : 'm L.program) :
|
||||
~f:(fun (ctxt, rev_items) code_item var ->
|
||||
match code_item with
|
||||
| ScopeDef (name, body) ->
|
||||
let scope_input_var, scope_body_expr, ctxt1 =
|
||||
let scope_input_var, scope_body_expr, outer_ctx =
|
||||
unbind ctxt body.scope_body_expr
|
||||
in
|
||||
let input_pos = Mark.get (ScopeName.get_info name) in
|
||||
let scope_input_var_id, ctxt =
|
||||
let scope_input_var_id, inner_ctx =
|
||||
register_fresh_var ctxt scope_input_var ~pos:input_pos
|
||||
in
|
||||
let new_scope_body =
|
||||
translate_scope_body_expr
|
||||
{ ctxt with context_name = Mark.remove (ScopeName.get_info name) }
|
||||
{
|
||||
inner_ctx with
|
||||
context_name = Mark.remove (ScopeName.get_info name);
|
||||
}
|
||||
scope_body_expr
|
||||
in
|
||||
let func_id, ctxt1 = register_fresh_func ctxt1 var ~pos:input_pos in
|
||||
( ctxt1,
|
||||
let func_id, outer_ctx =
|
||||
register_fresh_func outer_ctx var ~pos:input_pos
|
||||
in
|
||||
( outer_ctx,
|
||||
A.SScope
|
||||
{
|
||||
Ast.scope_body_name = name;
|
||||
@ -841,32 +826,32 @@ let translate_program ~(config : translation_config) (p : 'm L.program) :
|
||||
:: rev_items )
|
||||
| Topdef (name, topdef_ty, _vis, (EAbs abs, m)) ->
|
||||
(* Toplevel function def *)
|
||||
let (block, expr, _ren_ctx), args_id =
|
||||
let args_a, expr, ctxt = unmbind ctxt abs.binder in
|
||||
let (block, expr, _ren_ctx_inner), args_id =
|
||||
let args_a, expr, ctxt_inner = unmbind ctxt abs.binder in
|
||||
let args = Array.to_list args_a in
|
||||
let rargs_id, ctxt =
|
||||
let rargs_id, ctxt_inner =
|
||||
List.fold_left2
|
||||
(fun (rargs_id, ctxt) v ty ->
|
||||
(fun (rargs_id, ctxt_inner) v ty ->
|
||||
let pos = Mark.get ty in
|
||||
let id, ctxt = register_fresh_var ctxt v ~pos in
|
||||
((id, pos), ty) :: rargs_id, ctxt)
|
||||
([], ctxt) args abs.tys
|
||||
let id, ctxt_inner = register_fresh_var ctxt_inner v ~pos in
|
||||
((id, pos), ty) :: rargs_id, ctxt_inner)
|
||||
([], ctxt_inner) args abs.tys
|
||||
in
|
||||
let ctxt =
|
||||
let ctxt_inner =
|
||||
{
|
||||
ctxt with
|
||||
ctxt_inner with
|
||||
context_name = Mark.remove (TopdefName.get_info name);
|
||||
}
|
||||
in
|
||||
translate_expr ctxt expr, List.rev rargs_id
|
||||
translate_expr ctxt_inner expr, List.rev rargs_id
|
||||
in
|
||||
let body_block =
|
||||
RevBlock.rebuild block ~tail:[A.SReturn expr, Mark.get expr]
|
||||
in
|
||||
let func_id, ctxt =
|
||||
let func_id, ctxt_outer =
|
||||
register_fresh_func ctxt var ~pos:(Expr.mark_pos m)
|
||||
in
|
||||
( ctxt,
|
||||
( ctxt_outer,
|
||||
A.SFunc
|
||||
{
|
||||
var = func_id;
|
||||
@ -884,7 +869,7 @@ let translate_program ~(config : translation_config) (p : 'm L.program) :
|
||||
:: rev_items )
|
||||
| Topdef (name, topdef_ty, _vis, expr) ->
|
||||
(* Toplevel constant def *)
|
||||
let block, expr, _ren_ctx =
|
||||
let block, expr, _ren_ctx_inner =
|
||||
let ctxt =
|
||||
{
|
||||
ctxt with
|
||||
|
@ -69,8 +69,8 @@ let renaming =
|
||||
Renaming.program ()
|
||||
~reserved:c_keywords
|
||||
(* TODO: add catala runtime built-ins as reserved as well ? *)
|
||||
~reset_context_for_closed_terms:false ~skip_constant_binders:true
|
||||
~constant_binder_name:None ~namespaced_fields_constrs:false
|
||||
~skip_constant_binders:true ~constant_binder_name:None
|
||||
~namespaced_fields_constrs:false
|
||||
|
||||
module TypMap = Map.Make (struct
|
||||
type t = naked_typ
|
||||
|
@ -167,9 +167,9 @@ let renaming =
|
||||
Renaming.program ()
|
||||
~reserved:python_keywords
|
||||
(* TODO: add catala runtime built-ins as reserved as well ? *)
|
||||
~reset_context_for_closed_terms:false ~skip_constant_binders:false
|
||||
~constant_binder_name:None ~namespaced_fields_constrs:true
|
||||
~f_struct:String.to_camel_case ~f_enum:String.to_camel_case
|
||||
~skip_constant_binders:false ~constant_binder_name:None
|
||||
~namespaced_fields_constrs:true ~f_struct:String.to_camel_case
|
||||
~f_enum:String.to_camel_case
|
||||
|
||||
let typ_needs_parens (e : typ) : bool =
|
||||
match Mark.remove e with TArrow _ | TArray _ -> true | _ -> false
|
||||
|
@ -75,7 +75,6 @@ module type BindlibCtxt = module type of Bindlib.Ctxt (DefaultBindlibCtxRename)
|
||||
type config = {
|
||||
reserved : string list;
|
||||
sanitize_varname : string -> string;
|
||||
reset_context_for_closed_terms : bool;
|
||||
skip_constant_binders : bool;
|
||||
constant_binder_name : string option;
|
||||
}
|
||||
@ -96,41 +95,37 @@ let default_config =
|
||||
{
|
||||
reserved = [];
|
||||
sanitize_varname = Fun.id;
|
||||
reset_context_for_closed_terms = true;
|
||||
skip_constant_binders = true;
|
||||
constant_binder_name = None;
|
||||
}
|
||||
|
||||
let patch_binder_name fname b =
|
||||
let name = fname (Bindlib.binder_name b) in
|
||||
let occurs = Bindlib.binder_occur b in
|
||||
let rank = Bindlib.binder_rank b in
|
||||
let mkfree v = EVar v in
|
||||
let subst = Bindlib.subst b in
|
||||
Bindlib.raw_binder name occurs rank mkfree subst
|
||||
|
||||
let patch_mbinder_names fname b =
|
||||
let names = Array.map fname (Bindlib.mbinder_names b) in
|
||||
let occurs = Bindlib.mbinder_occurs b in
|
||||
let rank = Bindlib.mbinder_rank b in
|
||||
let mkfree v = EVar v in
|
||||
let msubst = Bindlib.msubst b in
|
||||
Bindlib.raw_mbinder names occurs rank mkfree msubst
|
||||
|
||||
let unbind_in ctx ?fname b =
|
||||
let module BindCtx = (val ctx.bindCtx) in
|
||||
match fname with
|
||||
| Some fn ->
|
||||
let name = fn (Bindlib.binder_name b) in
|
||||
let v, bcontext = BindCtx.new_var_in ctx.bcontext (fun v -> EVar v) name in
|
||||
let e = Bindlib.subst b (EVar v) in
|
||||
v, e, { ctx with bcontext }
|
||||
| None ->
|
||||
let v, e, bcontext = BindCtx.unbind_in ctx.bcontext b in
|
||||
v, e, { ctx with bcontext }
|
||||
let b = match fname with Some fn -> patch_binder_name fn b | None -> b in
|
||||
let v, e, bcontext = BindCtx.unbind_in ctx.bcontext b in
|
||||
v, e, { ctx with bcontext }
|
||||
|
||||
let unmbind_in ctx ?fname b =
|
||||
let module BindCtx = (val ctx.bindCtx) in
|
||||
match fname with
|
||||
| Some fn ->
|
||||
let names = Array.map fn (Bindlib.mbinder_names b) in
|
||||
let rvs, bcontext =
|
||||
Array.fold_left
|
||||
(fun (rvs, bcontext) n ->
|
||||
let v, bcontext = BindCtx.new_var_in bcontext (fun v -> EVar v) n in
|
||||
v :: rvs, bcontext)
|
||||
([], ctx.bcontext) names
|
||||
in
|
||||
let vs = Array.of_list (List.rev rvs) in
|
||||
let e = Bindlib.msubst b (Array.map (fun v -> EVar v) vs) in
|
||||
vs, e, { ctx with bcontext }
|
||||
| None ->
|
||||
let vs, e, bcontext = BindCtx.unmbind_in ctx.bcontext b in
|
||||
vs, e, { ctx with bcontext }
|
||||
let b = match fname with Some fn -> patch_mbinder_names fn b | None -> b in
|
||||
let vs, e, bcontext = BindCtx.unmbind_in ctx.bcontext b in
|
||||
vs, e, { ctx with bcontext }
|
||||
|
||||
let set_rewriters ?scopes ?topdefs ?structs ?fields ?enums ?constrs ctx =
|
||||
(fun ?(scopes = ctx.scopes) ?(topdefs = ctx.topdefs) ?(structs = ctx.structs)
|
||||
@ -152,7 +147,6 @@ let get_ctx cfg =
|
||||
let module BindCtx = Bindlib.Ctxt (struct
|
||||
include DefaultBindlibCtxRename
|
||||
|
||||
let reset_context_for_closed_terms = cfg.reset_context_for_closed_terms
|
||||
let skip_constant_binders = cfg.skip_constant_binders
|
||||
let constant_binder_name = cfg.constant_binder_name
|
||||
end) in
|
||||
@ -255,7 +249,7 @@ let code_items ctx fty (items : 'e code_item_list) =
|
||||
(function EVar v -> Bindlib.box_var v | _ -> assert false)
|
||||
l)
|
||||
in
|
||||
Bindlib.box_apply (fun l -> Last l) l
|
||||
Bindlib.box_apply (fun l -> Last l) l, ctx
|
||||
| Cons (ScopeDef (name, body), next_bind) ->
|
||||
let scope_body =
|
||||
let scope_input_var, scope_lets, ctx =
|
||||
@ -287,10 +281,12 @@ let code_items ctx fty (items : 'e code_item_list) =
|
||||
(* Otherwise, it is treated as a normal variable *)
|
||||
unbind_in ctx ~fname:ctx.vars next_bind
|
||||
in
|
||||
let next_bind = Bindlib.bind_var scope_var (aux ctx next) in
|
||||
Bindlib.box_apply2
|
||||
(fun body next_bind -> Cons (ScopeDef (name, body), next_bind))
|
||||
scope_body next_bind
|
||||
let next_body, ctx = aux ctx next in
|
||||
let next_bind = Bindlib.bind_var scope_var next_body in
|
||||
( Bindlib.box_apply2
|
||||
(fun body next_bind -> Cons (ScopeDef (name, body), next_bind))
|
||||
scope_body next_bind,
|
||||
ctx )
|
||||
| Cons (Topdef (name, ty, visibility, e), next_bind) ->
|
||||
let e = expr ctx e in
|
||||
let ty = fty ty in
|
||||
@ -306,12 +302,16 @@ let code_items ctx fty (items : 'e code_item_list) =
|
||||
(* Otherwise, it is treated as a normal variable *)
|
||||
unbind_in ctx ~fname:ctx.vars next_bind
|
||||
in
|
||||
let next_bind = Bindlib.bind_var topdef_var (aux ctx next) in
|
||||
Bindlib.box_apply2
|
||||
(fun e next_bind -> Cons (Topdef (name, ty, visibility, e), next_bind))
|
||||
(Expr.Box.lift e) next_bind
|
||||
let next_body, ctx = aux ctx next in
|
||||
let next_bind = Bindlib.bind_var topdef_var next_body in
|
||||
( Bindlib.box_apply2
|
||||
(fun e next_bind ->
|
||||
Cons (Topdef (name, ty, visibility, e), next_bind))
|
||||
(Expr.Box.lift e) next_bind,
|
||||
ctx )
|
||||
in
|
||||
Bindlib.unbox (aux ctx items)
|
||||
let items, ctx = aux ctx items in
|
||||
Bindlib.unbox items, ctx
|
||||
|
||||
module PathMap = Map.Make (Uid.Path)
|
||||
|
||||
@ -434,7 +434,6 @@ let uncap s = String.to_ascii s |> String.uncapitalize_ascii
|
||||
names *)
|
||||
let program
|
||||
~reserved
|
||||
~reset_context_for_closed_terms
|
||||
~skip_constant_binders
|
||||
~constant_binder_name
|
||||
~namespaced_fields_constrs
|
||||
@ -448,7 +447,6 @@ let program
|
||||
{
|
||||
reserved;
|
||||
sanitize_varname = f_var;
|
||||
reset_context_for_closed_terms;
|
||||
skip_constant_binders;
|
||||
constant_binder_name;
|
||||
}
|
||||
@ -608,7 +606,7 @@ let program
|
||||
}
|
||||
in
|
||||
let decl_ctx = Program.map_decl_ctx ~f:(typ ctx) decl_ctx in
|
||||
let code_items = code_items ctx (typ ctx) p.code_items in
|
||||
let code_items, ctx = code_items ctx (typ ctx) p.code_items in
|
||||
{ p with decl_ctx; code_items }, ctx
|
||||
|
||||
(* This first-class module wrapping is here to allow a polymorphic renaming
|
||||
@ -624,7 +622,6 @@ let apply (module R : Renaming) = R.apply
|
||||
|
||||
let program
|
||||
~reserved
|
||||
~reset_context_for_closed_terms
|
||||
~skip_constant_binders
|
||||
~constant_binder_name
|
||||
~namespaced_fields_constrs
|
||||
@ -636,14 +633,14 @@ let program
|
||||
() =
|
||||
let module M = struct
|
||||
let apply p =
|
||||
program ~reserved ~reset_context_for_closed_terms ~skip_constant_binders
|
||||
~constant_binder_name ~namespaced_fields_constrs ?f_var ?f_struct
|
||||
?f_field ?f_enum ?f_constr p
|
||||
program ~reserved ~skip_constant_binders ~constant_binder_name
|
||||
~namespaced_fields_constrs ?f_var ?f_struct ?f_field ?f_enum ?f_constr p
|
||||
end in
|
||||
(module M : Renaming)
|
||||
|
||||
let default =
|
||||
program () ~reserved:[] ~reset_context_for_closed_terms:true
|
||||
~skip_constant_binders:true ~constant_binder_name:(Some "_") ~f_var:Fun.id
|
||||
program () ~reserved:default_config.reserved
|
||||
~skip_constant_binders:default_config.skip_constant_binders
|
||||
~constant_binder_name:default_config.constant_binder_name ~f_var:Fun.id
|
||||
~f_struct:Fun.id ~f_field:Fun.id ~f_enum:Fun.id ~f_constr:Fun.id
|
||||
~namespaced_fields_constrs:true
|
||||
|
@ -20,7 +20,6 @@ open Definitions
|
||||
type config = {
|
||||
reserved : string list; (** Use for keywords and built-ins *)
|
||||
sanitize_varname : string -> string; (** Typically String.to_snake_case *)
|
||||
reset_context_for_closed_terms : bool; (** See [Bindlib.Renaming] *)
|
||||
skip_constant_binders : bool; (** See [Bindlib.Renaming] *)
|
||||
constant_binder_name : string option; (** See [Bindlib.Renaming] *)
|
||||
}
|
||||
@ -73,7 +72,7 @@ val code_items :
|
||||
context ->
|
||||
(typ -> typ) ->
|
||||
((_ any, 'm) gexpr as 'e) code_item_list ->
|
||||
'e code_item_list
|
||||
'e code_item_list * context
|
||||
|
||||
type t
|
||||
(** Enclosing of a polymorphic renaming function, to be used by [apply] *)
|
||||
@ -82,7 +81,6 @@ val apply : t -> 'e program -> 'e program * context
|
||||
|
||||
val program :
|
||||
reserved:string list ->
|
||||
reset_context_for_closed_terms:bool ->
|
||||
skip_constant_binders:bool ->
|
||||
constant_binder_name:string option ->
|
||||
namespaced_fields_constrs:bool ->
|
||||
|
@ -100,8 +100,8 @@ const Baz* baz (const Baz_in* baz_in)
|
||||
b3 = CATALA_NONE;
|
||||
}
|
||||
if (b3->code == catala_option_some) {
|
||||
CATALA_DEC x = b3->payload;
|
||||
b2 = catala_some(x);
|
||||
CATALA_DEC x1 = b3->payload;
|
||||
b2 = catala_some(x1);
|
||||
} else {
|
||||
CATALA_DEC b5;
|
||||
switch (a1->code) {
|
||||
@ -124,8 +124,8 @@ const Baz* baz (const Baz_in* baz_in)
|
||||
b2 = catala_some(b5);
|
||||
}
|
||||
if (b2->code == catala_option_some) {
|
||||
CATALA_DEC arg = b2->payload;
|
||||
b1 = arg;
|
||||
CATALA_DEC arg1 = b2->payload;
|
||||
b1 = arg1;
|
||||
} else {
|
||||
static const catala_code_position pos[1] =
|
||||
{{"tests/backends/simple.catala_en", 12, 10, 12, 11}};
|
||||
@ -138,8 +138,8 @@ const Baz* baz (const Baz_in* baz_in)
|
||||
c3->elements[1] = b;
|
||||
c2 = catala_some(c3);
|
||||
if (c2->code == catala_option_some) {
|
||||
const CATALA_ARRAY(CATALA_DEC) arg = c2->payload;
|
||||
c1 = arg;
|
||||
const CATALA_ARRAY(CATALA_DEC) arg2 = c2->payload;
|
||||
c1 = arg2;
|
||||
} else {
|
||||
static const catala_code_position pos[1] =
|
||||
{{"tests/backends/simple.catala_en", 13, 10, 13, 11}};
|
||||
|
@ -116,11 +116,11 @@ def b(b_in:BIn):
|
||||
arg = result2
|
||||
result1 = (arg)
|
||||
result = (some_name(SomeNameIn(i_in = result1)))
|
||||
result2 = (SomeName(o = result.o))
|
||||
result3 = (SomeName(o = result.o))
|
||||
if True:
|
||||
some_name2 = (result2)
|
||||
some_name2 = (result3)
|
||||
else:
|
||||
some_name2 = (result2)
|
||||
some_name2 = (result3)
|
||||
some_name1 = (some_name2)
|
||||
return B(some_name = some_name1)
|
||||
```
|
||||
|
@ -24,7 +24,7 @@ module S_in = struct
|
||||
end
|
||||
|
||||
|
||||
let s (s_in: S_in.t) : S.t =
|
||||
let s (_: S_in.t) : S.t =
|
||||
let sr: money =
|
||||
match (Eoption.ESome (money_of_cents_string "100000"))
|
||||
with
|
||||
@ -54,7 +54,7 @@ let half : integer -> decimal =
|
||||
"2")
|
||||
|
||||
let maybe : Enum1.t -> Enum1.t =
|
||||
fun (x: Enum1.t) -> Enum1.Maybe ()
|
||||
fun (_: Enum1.t) -> Enum1.Maybe ()
|
||||
|
||||
let () =
|
||||
Runtime_ocaml.Runtime.register_module "Mod_def"
|
||||
|
@ -34,11 +34,11 @@ module Closure_scoppe1_in = struct
|
||||
end
|
||||
|
||||
|
||||
let closure_scoppe (closure_scoppe_in: Closure_scoppe_in.t) : Closure_scoppe.t =
|
||||
let closure_scoppe (_: Closure_scoppe_in.t) : Closure_scoppe.t =
|
||||
let scoppe: bool = false in
|
||||
{Closure_scoppe.scoppe = scoppe}
|
||||
|
||||
let closure_scoppe1 (closure_scoppe1_in: Closure_scoppe1_in.t) : Closure_scoppe1.t =
|
||||
let closure_scoppe1 (_: Closure_scoppe1_in.t) : Closure_scoppe1.t =
|
||||
let scoppe: bool = false in
|
||||
{Closure_scoppe1.scoppe = scoppe}
|
||||
|
||||
@ -93,17 +93,17 @@ end
|
||||
|
||||
|
||||
let closure_scoppe2 : Obj.t -> bool -> integer -> bool =
|
||||
fun (env: Obj.t) (acc: bool) (x: integer) ->
|
||||
fun (_: Obj.t) (acc: bool) (x: integer) ->
|
||||
o_and acc (o_gt_int_int x (integer_of_string "2"))
|
||||
|
||||
let closure_scoppe (closure_scoppe_in: Closure_scoppe_in.t) : Closure_scoppe.t =
|
||||
let closure_scoppe (_: Closure_scoppe_in.t) : Closure_scoppe.t =
|
||||
let scoppe: bool =
|
||||
o_fold (closure_scoppe2, (o_toclosureenv ())) true
|
||||
([|(integer_of_string "5"); (integer_of_string "6"); (integer_of_string
|
||||
"7")|]) in
|
||||
{Closure_scoppe.scoppe = scoppe}
|
||||
|
||||
let closure_scoppe1 (closure_scoppe1_in: Closure_scoppe1_in.t) : Closure_scoppe1.t =
|
||||
let closure_scoppe1 (_: Closure_scoppe1_in.t) : Closure_scoppe1.t =
|
||||
let scoppe: bool = false in
|
||||
{Closure_scoppe1.scoppe = scoppe}
|
||||
|
||||
|
@ -131,16 +131,16 @@ end
|
||||
|
||||
|
||||
let closure_assert : Obj.t -> integer -> integer =
|
||||
fun (env: Obj.t) (x: integer) -> (let env1 : unit = (o_fromclosureenv env)
|
||||
fun (env: Obj.t) (x: integer) -> (let _ : unit = (o_fromclosureenv env)
|
||||
in
|
||||
((o_add_int_int x (integer_of_string "1"))))
|
||||
|
||||
let assert1 (assert_in: Assert_in1.t) : Assert2.t =
|
||||
let assert1 (_: Assert_in1.t) : Assert2.t =
|
||||
let assert1: bool =
|
||||
match
|
||||
(match
|
||||
(Eoption.ESome
|
||||
(let assert1 : integer array =
|
||||
(let _ : integer array =
|
||||
(o_map
|
||||
(let assert1 : Obj.t -> integer -> integer = closure_assert
|
||||
in
|
||||
|
@ -64,7 +64,7 @@ let s (s_in: S_in.t) : S.t =
|
||||
(let a2 : bool = (o_or a1 true) in
|
||||
a2)))
|
||||
with
|
||||
| Eoption.ENone _1 -> (raise
|
||||
| Eoption.ENone _ -> (raise
|
||||
(Runtime_ocaml.Runtime.Error (NoValue, [{filename="tests/name_resolution/good/let_in2.catala_en";
|
||||
start_line=7; start_column=18;
|
||||
end_line=7; end_column=19;
|
||||
|
@ -124,7 +124,7 @@ let glob5 = glob5_init ()
|
||||
|
||||
let glob6 = A {"y": glob1 >= 30., "z": 123. * 17.}
|
||||
|
||||
let S2 (_: S2_in) =
|
||||
let S2 (s2_in: S2_in) =
|
||||
decl a1 : decimal;
|
||||
a2 : option decimal = ESome glob3 ¤44.00 + 100.;
|
||||
switch a2:
|
||||
@ -137,7 +137,7 @@ let S2 (_: S2_in) =
|
||||
a = a1;
|
||||
return S2 {"a": a}
|
||||
|
||||
let S3 (_: S3_in) =
|
||||
let S3 (s3_in: S3_in) =
|
||||
decl a1 : decimal;
|
||||
a2 : option decimal = ESome 50. + glob4 ¤44.00 55.;
|
||||
switch a2:
|
||||
@ -150,7 +150,7 @@ let S3 (_: S3_in) =
|
||||
a = a1;
|
||||
return S3 {"a": a}
|
||||
|
||||
let S4 (_: S4_in) =
|
||||
let S4 (s4_in: S4_in) =
|
||||
decl a1 : decimal;
|
||||
a2 : option decimal = ESome glob5 + 1.;
|
||||
switch a2:
|
||||
@ -163,7 +163,7 @@ let S4 (_: S4_in) =
|
||||
a = a1;
|
||||
return S4 {"a": a}
|
||||
|
||||
let S5 (_: S_in) =
|
||||
let S5 (s_in: S_in) =
|
||||
decl a1 : decimal;
|
||||
a2 : option decimal = ESome glob1 * glob1;
|
||||
switch a2:
|
||||
@ -180,8 +180,8 @@ let S5 (_: S_in) =
|
||||
| ENone _ →
|
||||
pos : SourcePosition = <toplevel_defs:8.10-11>;
|
||||
fatal NoValue
|
||||
| ESome arg →
|
||||
b1 = arg;
|
||||
| ESome arg1 →
|
||||
b1 = arg1;
|
||||
decl b : A {y: bool; z: decimal};
|
||||
b = b1;
|
||||
return S {"a": a, "b": b}
|
||||
@ -431,8 +431,8 @@ def s5(s_in:SIn):
|
||||
law_headings=["Test basic toplevel values defs"]))
|
||||
raise NoValue(pos)
|
||||
else:
|
||||
arg = b2
|
||||
b1 = (arg)
|
||||
arg1 = b2
|
||||
b1 = (arg1)
|
||||
b = (b1)
|
||||
return S(a = a, b = b)
|
||||
```
|
||||
|
@ -53,11 +53,10 @@ module ScopeB_in = struct
|
||||
end
|
||||
|
||||
|
||||
let scope_a (scope_a_in: ScopeA_in.t) : ScopeA.t =
|
||||
let a: bool = true in
|
||||
{ScopeA.a = a}
|
||||
let scope_a (_: ScopeA_in.t) : ScopeA.t = let a: bool = true in
|
||||
{ScopeA.a = a}
|
||||
|
||||
let scope_b (scope_b_in: ScopeB_in.t) : ScopeB.t =
|
||||
let scope_b (_: ScopeB_in.t) : ScopeB.t =
|
||||
let scope_a1: ScopeA.t = {ScopeA.a = ((scope_a (())).ScopeA.a)} in
|
||||
let a: bool = scope_a1.ScopeA.a in
|
||||
{ScopeB.a = a}
|
||||
|
@ -39,7 +39,7 @@ $ catala Scalc -s Foo2 -O -t
|
||||
│ 5 │ output bar content integer
|
||||
│ │ ‾‾‾
|
||||
└─ Test
|
||||
let Foo2 (_: Foo2_in) =
|
||||
let Foo2 (foo2_in: Foo2_in) =
|
||||
decl bar1 : integer;
|
||||
pos : SourcePosition = <nothing:5.10-13>;
|
||||
fatal NoValue;
|
||||
|
Loading…
Reference in New Issue
Block a user