diff --git a/src/passes/6-transpiler/transpiler.ml b/src/passes/6-transpiler/transpiler.ml index 346791a30..470eb726e 100644 --- a/src/passes/6-transpiler/transpiler.ml +++ b/src/passes/6-transpiler/transpiler.ml @@ -280,7 +280,13 @@ 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 - return @@ E_application (a, b) + let%bind b' = Self_mini_c.Helpers.map_expression + (fun exp -> + match exp.type_value with + | T_deep_closure _ -> fail @@ simple_error "Cannot apply closure in function argument" + | _ -> ok exp + ) b in + 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 8ab9fdfec..9408fd36a 100644 --- a/src/test/contracts/high-order.ligo +++ b/src/test/contracts/high-order.ligo @@ -15,4 +15,11 @@ function higher2(const i: int; const f: int -> int): int is function foobar2 (const i : int) : int is function foo2 (const i : int) : int is block { skip } with i; - block { skip } with higher2(i,foo2) \ No newline at end of file + 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) \ No newline at end of file diff --git a/src/test/integration_tests.ml b/src/test/integration_tests.ml index e48a10e9a..f5b4a7aad 100644 --- a/src/test/integration_tests.ml +++ b/src/test/integration_tests.ml @@ -110,15 +110,12 @@ let shadow () : unit result = let higher_order () : unit result = let%bind program = type_file "./contracts/high-order.ligo" in - let%bind _ = - let make_expect = fun n -> n in - expect_eq_n_int program "foobar" make_expect - in - let%bind _ = - let make_expect = fun n -> n in - expect_eq_n_int program "foobar2" make_expect - in - ok () + 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 *) + ok () let shared_function () : unit result = let%bind program = type_file "./contracts/function-shared.ligo" in