we don't need to check for closures in function arguments
This commit is contained in:
parent
27be6cfcba
commit
9f0b61659e
@ -287,21 +287,7 @@ and transpile_annotated_expression (ae:AST.annotated_expression) : expression re
|
|||||||
| E_application (a, b) ->
|
| E_application (a, b) ->
|
||||||
let%bind a = transpile_annotated_expression a in
|
let%bind a = transpile_annotated_expression a in
|
||||||
let%bind b = transpile_annotated_expression b in
|
let%bind b = transpile_annotated_expression b in
|
||||||
let%bind contains_closure =
|
return @@ E_application (a, b)
|
||||||
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)
|
|
||||||
| E_constructor (m, param) -> (
|
| E_constructor (m, param) -> (
|
||||||
let%bind param' = transpile_annotated_expression param in
|
let%bind param' = transpile_annotated_expression param in
|
||||||
let (param'_expr , param'_tv) = Combinators.Expression.(get_content param' , get_type param') in
|
let (param'_expr , param'_tv) = Combinators.Expression.(get_content param' , get_type param') in
|
||||||
|
@ -17,12 +17,11 @@ function foobar2 (const i : int) : int is
|
|||||||
block { skip } with i;
|
block { skip } with i;
|
||||||
block { skip } with higher2(i,foo2)
|
block { skip } with higher2(i,foo2)
|
||||||
|
|
||||||
// This is not supported yet:
|
const a : int = 0;
|
||||||
// const a : int = 123;
|
function foobar3 (const i : int) : int is
|
||||||
// function foobar3 (const i : int) : int is
|
function foo2 (const i : int) : int is
|
||||||
// function foo2 (const i : int) : int is
|
block { skip } with (a+i);
|
||||||
// block { skip } with (a+i);
|
block { skip } with higher2(i,foo2)
|
||||||
// block { skip } with higher2(i,foo2)
|
|
||||||
|
|
||||||
function f (const i : int) : int is
|
function f (const i : int) : int is
|
||||||
block { skip }
|
block { skip }
|
||||||
|
@ -113,8 +113,7 @@ let higher_order () : unit result =
|
|||||||
let make_expect = fun n -> n 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 "foobar" make_expect in
|
||||||
let%bind _ = expect_eq_n_int program "foobar2" 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
|
let%bind _ = expect_eq_n_int program "foobar4" make_expect in
|
||||||
ok ()
|
ok ()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user