From 9f0b61659e10300ce1cf29986510d1d2cf246f84 Mon Sep 17 00:00:00 2001 From: Lesenechal Remi Date: Thu, 17 Oct 2019 17:18:10 +0200 Subject: [PATCH] we don't need to check for closures in function arguments --- src/passes/6-transpiler/transpiler.ml | 16 +--------------- src/test/contracts/high-order.ligo | 11 +++++------ src/test/integration_tests.ml | 3 +-- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/passes/6-transpiler/transpiler.ml b/src/passes/6-transpiler/transpiler.ml index 5886ab542..eb2fe4b54 100644 --- a/src/passes/6-transpiler/transpiler.ml +++ b/src/passes/6-transpiler/transpiler.ml @@ -287,21 +287,7 @@ and transpile_annotated_expression (ae:AST.annotated_expression) : expression re | E_application (a, b) -> let%bind a = transpile_annotated_expression a in let%bind b = transpile_annotated_expression b in - let%bind contains_closure = - Self_mini_c.Helpers.fold_type_value - (fun contains_closure exp -> - ok (contains_closure - || match exp with - | T_deep_closure _ -> true - | _ -> false)) - false - b.type_value in - if contains_closure - then - let errmsg = Format.asprintf "Cannot apply closure in function arguments: %a\n" - Mini_c.PP.expression_with_type b in - fail @@ simple_error errmsg - else return @@ E_application (a, b) + return @@ E_application (a, b) | E_constructor (m, param) -> ( let%bind param' = transpile_annotated_expression param in let (param'_expr , param'_tv) = Combinators.Expression.(get_content param' , get_type param') in diff --git a/src/test/contracts/high-order.ligo b/src/test/contracts/high-order.ligo index d3c83170a..9059b1efb 100644 --- a/src/test/contracts/high-order.ligo +++ b/src/test/contracts/high-order.ligo @@ -17,12 +17,11 @@ function foobar2 (const i : int) : int is block { skip } with i; block { skip } with higher2(i,foo2) -// This is not supported yet: -// const a : int = 123; -// function foobar3 (const i : int) : int is -// function foo2 (const i : int) : int is -// block { skip } with (a+i); -// block { skip } with higher2(i,foo2) +const a : int = 0; +function foobar3 (const i : int) : int is + function foo2 (const i : int) : int is + block { skip } with (a+i); + block { skip } with higher2(i,foo2) function f (const i : int) : int is block { skip } diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index 89e5ef967..a7fc3858a 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -113,8 +113,7 @@ let higher_order () : unit result = let make_expect = fun n -> n in let%bind _ = expect_eq_n_int program "foobar" make_expect in let%bind _ = expect_eq_n_int program "foobar2" make_expect in - (* not supported yet: - let%bind _ = expect_eq_n_int program "foobar3" make_expect in *) + let%bind _ = expect_eq_n_int program "foobar3" make_expect in let%bind _ = expect_eq_n_int program "foobar4" make_expect in ok ()