Merge branch 'fix-reasonligo-functiontype-parsing' into 'dev'

fix annotation for funciton in ReasonLigo

Closes #164

See merge request ligolang/ligo!489
This commit is contained in:
Pierre-Emmanuel Wulfman 2020-03-08 20:18:10 +00:00
commit 6a09ac866c
5 changed files with 21 additions and 6 deletions

View File

@ -310,7 +310,7 @@ let main (action, store: parameter * storage) : return =
```reasonligo group=c
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);
let main = ((action, store) : (parameter, storage)) : storage => {
let main = ((action, store) : (parameter, storage)) : return => {
if (Tezos.source != owner) { (failwith ("Access denied.") : return); }
else { (([] : list (operation)), store); };
};
@ -478,4 +478,3 @@ let proxy = ((action, store): (parameter, storage)) : return => {
> *deprecated*.
</Syntax>

View File

@ -558,9 +558,13 @@ fun_expr:
in raise (Error (WrongFunctionArguments e))
in
let binders = fun_args_to_pattern $1 in
let lhs_type = match $1 with
EAnnot {value = {inside = _ , _, t; _}; region = r} -> Some (r,t)
| _ -> None
in
let f = {kwd_fun;
binders;
lhs_type=None;
lhs_type;
arrow;
body
}

View File

@ -828,6 +828,18 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result
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 lhs_type = match lhs_type with
| None -> (match let_rhs with
| EFun {value={binders;lhs_type}} ->
let f_args = nseq_to_list (binders) in
let%bind lhs_type' = bind_map_option (fun x -> simpl_type_expression (snd x)) lhs_type 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 @@ (List.fold_right' aux lhs_type' ty)
| _ -> ok None
)
| Some t -> ok @@ Some t
in
ok @@ [loc x @@ (Declaration_constant (Var.of_name var.value , lhs_type , inline, rhs'))]
)

View File

@ -12,7 +12,7 @@ generated. unrecognized constant: {"constant":"BALANCE","location":"generated"}
type storage = tez;
let main2 = (p : unit, storage) =>
let main2 = (p : unit, s: storage) =>
([]: list (operation), Tezos.balance);
let main = (x : (unit, storage)) => main2 (x[0], x[1]);

View File

@ -9,7 +9,7 @@ let add_op = (s: set (string)) : set (string) =>
let remove_op = (s: set (string)) : set (string) =>
Set.remove ("foobar", s);
let remove_deep = (s: (set (string), nat)): (set (string), nat) =>
let remove_deep = (s: (set (string), nat)): set (string) =>
Set.remove ("foobar", s[0]);
let mem_op = (s: set (string)) : bool =>