Check for closure when applying a function and update tests
This commit is contained in:
parent
a7565145d5
commit
6fbe43d28a
@ -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
|
||||
|
@ -16,3 +16,10 @@ function foobar2 (const i : int) : int is
|
||||
function foo2 (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)
|
@ -110,14 +110,11 @@ 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
|
||||
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 =
|
||||
|
Loading…
Reference in New Issue
Block a user