Works also when the function parameter are passed in the rhs
Fix some religo contract
This commit is contained in:
parent
6e35dadcc4
commit
89f2b44e7d
@ -812,10 +812,8 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result
|
|||||||
ok (var , tl)
|
ok (var , tl)
|
||||||
in
|
in
|
||||||
let%bind lhs_type' = bind_map_option (fun x -> simpl_type_expression (snd x)) lhs_type in
|
let%bind lhs_type' = bind_map_option (fun x -> simpl_type_expression (snd x)) lhs_type in
|
||||||
match args with
|
let let_rhs = match args with
|
||||||
| [] ->
|
| [] -> let_rhs
|
||||||
let%bind rhs' = simpl_expression let_rhs in
|
|
||||||
ok @@ [loc x @@ (Declaration_constant (Var.of_name var.value , lhs_type' , inline, rhs'))]
|
|
||||||
| param1::others ->
|
| param1::others ->
|
||||||
let fun_ = {
|
let fun_ = {
|
||||||
kwd_fun = Region.ghost;
|
kwd_fun = Region.ghost;
|
||||||
@ -824,9 +822,15 @@ and simpl_declaration : Raw.declaration -> declaration Location.wrap list result
|
|||||||
arrow = Region.ghost;
|
arrow = Region.ghost;
|
||||||
body = let_rhs
|
body = let_rhs
|
||||||
} in
|
} in
|
||||||
let rhs = Raw.EFun {region=Region.ghost ; value=fun_} in
|
Raw.EFun {region=Region.ghost ; value=fun_}
|
||||||
let%bind rhs' = simpl_expression rhs in
|
in
|
||||||
let%bind ty = bind_map_list typed_pattern_to_typed_vars args in
|
let f_args = (match let_rhs with
|
||||||
|
| Raw.EFun f -> nseq_to_list f.value.binders
|
||||||
|
| _ -> []
|
||||||
|
)
|
||||||
|
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 aux acc ty = Option.map (t_function (snd ty)) acc in
|
||||||
let func_type = List.fold_right' aux lhs_type' ty 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 , func_type , inline, rhs'))]
|
||||||
|
@ -12,6 +12,6 @@ generated. unrecognized constant: {"constant":"BALANCE","location":"generated"}
|
|||||||
|
|
||||||
type storage = tez;
|
type storage = tez;
|
||||||
|
|
||||||
let main2 = (p: unit, storage) => ([]: list(operation), balance);
|
let main2 = (p: unit, s: storage) => ([]: list(operation), balance);
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
type storage = int;
|
type storage = int;
|
||||||
|
|
||||||
let main2 = (p: int, storage): string => ([]: list(operation), p + storage);
|
let main2 = (p: int, s: storage): string => ([]: list(operation), p + s);
|
||||||
|
|
||||||
let main = (x: (int, storage)) : string => main2(x[0],x[1]);
|
let main = (x: (int, storage)) : string => main2(x[0],x[1]);
|
||||||
|
|
||||||
|
@ -5,6 +5,6 @@ type storage = unit;
|
|||||||
(fun x -> ()) ()
|
(fun x -> ()) ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let main2 = ((p: unit), storage) => (((xxx: unit)) => ())();
|
let main2 = ((p: unit), s: storage) => (((xxx: unit)) => ())();
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0], x[1]);
|
let main = (x: (unit, storage)) => main2(x[0], x[1]);
|
||||||
|
@ -4,7 +4,7 @@ type storage = unit;
|
|||||||
let main (p:unit) storage = (fun x -> ()) ()
|
let main (p:unit) storage = (fun x -> ()) ()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
let main2 = (z: unit, storage) =>
|
let main2 = (z: unit, s: storage) =>
|
||||||
((f: (unit => unit)) => f())((z: unit) => unit);
|
((f: (unit => unit)) => f())((z: unit) => unit);
|
||||||
|
|
||||||
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
let main = (x: (unit, storage)) => main2(x[0],x[1]);
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
type storage = (int, int);
|
type storage = (int, int);
|
||||||
|
|
||||||
let main2 = ((n : int), storage) => {
|
let main2 = ((n : int), s: storage) => {
|
||||||
let x: (int, int) = {
|
let x: (int, int) = {
|
||||||
let x: int = 7;
|
let x: int = 7;
|
||||||
(x + n, storage[0] + storage[1]);
|
(x + n, s[0] + s[1]);
|
||||||
};
|
};
|
||||||
([]: list(operation), x);
|
([]: list(operation), x);
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ let x: list(int) = [];
|
|||||||
let y: list(int) = [3, 4, 5];
|
let y: list(int) = [3, 4, 5];
|
||||||
let z: list(int) = [2, ...y];
|
let z: list(int) = [2, ...y];
|
||||||
|
|
||||||
let main2 = (p: param, storage) => {
|
let main2 = (p: param, storage : storage) => {
|
||||||
let storage =
|
let storage =
|
||||||
switch (p) {
|
switch (p) {
|
||||||
| [] => storage
|
| [] => storage
|
||||||
|
@ -4,9 +4,9 @@ type param =
|
|||||||
| Add(int)
|
| Add(int)
|
||||||
| Sub(int);
|
| Sub(int);
|
||||||
|
|
||||||
let main2 = ((p: param), storage) => {
|
let main2 = ((p: param), s: storage) => {
|
||||||
let storage =
|
let storage =
|
||||||
storage
|
s
|
||||||
+ (
|
+ (
|
||||||
switch (p) {
|
switch (p) {
|
||||||
| Add(n) => n
|
| Add(n) => n
|
||||||
|
@ -12,7 +12,7 @@ let subtract = ((a: int), (b: int)) => a - b;
|
|||||||
|
|
||||||
/* real entrypoint that re-routes the flow based on the action provided */
|
/* real entrypoint that re-routes the flow based on the action provided */
|
||||||
|
|
||||||
let main2 = ((p: action), storage) => {
|
let main2 = ((p: action), storage : storage) => {
|
||||||
let storage =
|
let storage =
|
||||||
switch (p) {
|
switch (p) {
|
||||||
| Increment(n) => add(storage, n)
|
| Increment(n) => add(storage, n)
|
||||||
|
Loading…
Reference in New Issue
Block a user