From 4f13a33d46b2b18a409debab89e76f72de9a533b Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Wulfman Date: Tue, 3 Mar 2020 16:17:07 +0100 Subject: [PATCH] fix bug with wrong annotation at the beginning --- src/passes/2-simplify/cameligo.ml | 19 +++++++------------ test.mligo | 3 +++ 2 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 test.mligo diff --git a/src/passes/2-simplify/cameligo.ml b/src/passes/2-simplify/cameligo.ml index 222dee09f..910da246f 100644 --- a/src/passes/2-simplify/cameligo.ml +++ b/src/passes/2-simplify/cameligo.ml @@ -812,8 +812,8 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result ok (var , tl) in let%bind lhs_type' = bind_map_option (fun x -> simpl_type_expression (snd x)) lhs_type in - let let_rhs = match args with - | [] -> let_rhs + let%bind let_rhs,lhs_type = match args with + | [] -> ok (let_rhs, lhs_type') | param1::others -> let fun_ = { kwd_fun = Region.ghost; @@ -822,18 +822,13 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result arrow = Region.ghost; body = let_rhs } in - Raw.EFun {region=Region.ghost ; value=fun_} - in - let f_args = (match let_rhs with - | Raw.EFun f -> nseq_to_list f.value.binders - | _ -> [] - ) + let f_args = nseq_to_list (param1,others) in + let%bind ty = bind_map_list typed_pattern_to_typed_vars f_args in + let aux acc ty = Option.map (t_function (snd ty)) acc in + ok (Raw.EFun {region=Region.ghost ; value=fun_},List.fold_right' aux lhs_type' ty) in let%bind rhs' = simpl_expression let_rhs in - let%bind ty = bind_map_list typed_pattern_to_typed_vars f_args in - let aux acc ty = Option.map (t_function (snd ty)) acc in - let func_type = List.fold_right' aux lhs_type' ty in - ok @@ [loc x @@ (Declaration_constant (Var.of_name var.value , func_type , inline, rhs'))] + ok @@ [loc x @@ (Declaration_constant (Var.of_name var.value , lhs_type , inline, rhs'))] ) and simpl_cases : type a . (Raw.pattern * a) list -> (a, unit) matching_content result = diff --git a/test.mligo b/test.mligo new file mode 100644 index 000000000..5ad65e3f3 --- /dev/null +++ b/test.mligo @@ -0,0 +1,3 @@ +let f : int = fun (x, y : int*int) -> x + y +let g (x, y : int * int) : int = f (x, y) +