remove shadowing of lambda name over the constant name

This commit is contained in:
Lesenechal Remi 2019-10-27 11:34:26 +01:00
parent d651bfb3a3
commit 164e88e818

View File

@ -615,7 +615,7 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a
let output_type = body.type_annotation in
return (E_lambda {binder = fst binder ; body}) (t_function input_type output_type ())
)
| E_constant ( ("LIST_FOLD"|"MAP_FOLD"|"SET_FOLD") ,
| E_constant ( ("LIST_FOLD"|"MAP_FOLD"|"SET_FOLD") as opname ,
[ collect ;
init_record ;
( { expression = (I.E_lambda { binder = (name, None) ;
@ -624,28 +624,28 @@ and type_expression : environment -> ?tv_opt:O.type_value -> I.expression -> O.a
result }) ;
location = _ }) as _lambda
] ) ->
(* this special case is here force annotation of the lambda
(* this special case is here force annotation of the untyped lambda
generated by pascaligo's for_collect loop *)
let%bind lst' = bind_list @@ List.map (type_expression e) [collect ; init_record] in
let tv_lst = List.map get_type_annotation lst' in
let tv_col = List.nth tv_lst 0 in
let tv_out = List.nth tv_lst 1 in
let collect_inner_type = match tv_col.type_value' with
| O.T_constant ( ("list"|"set"|"map") , t) -> t
| O.T_constant ( ("list"|"set"|"map") , [t]) -> t
| _ -> failwith "impossible" in
let input_type = t_tuple (tv_out::collect_inner_type) () in
let input_type = t_tuple (tv_out::[collect_inner_type]) () in
let output_type = Some tv_out in
let e' = Environment.add_ez_binder name input_type e in
let e' = Environment.add_ez_binder "arguments" input_type e in
let%bind body = type_expression ?tv_opt:output_type e' result in
let output_type = body.type_annotation in
let%bind lambda' = ok @@ make_a_e (E_lambda {binder = name ; body}) (t_function input_type output_type ()) e in
let%bind lst' = ok @@ lst'@[lambda'] in
let tv_lst = List.map get_type_annotation lst' in
let%bind (name', tv) =
type_constant name tv_lst tv_opt ae.location in
return (E_constant (name' , lst')) tv
let%bind (opname', tv) =
type_constant opname tv_lst tv_opt ae.location in
return (E_constant (opname' , lst')) tv
| E_constant (name, lst) ->
let%bind lst' = bind_list @@ List.map (type_expression e) lst in
let tv_lst = List.map get_type_annotation lst' in