we don't need to check for closures in function arguments

This commit is contained in:
Lesenechal Remi 2019-10-17 17:18:10 +02:00
parent 27be6cfcba
commit 9f0b61659e
3 changed files with 7 additions and 23 deletions

View File

@ -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

View File

@ -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 }

View File

@ -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 ()