diff --git a/jscomp/ext_string.ml b/jscomp/ext_string.ml index de720c9936..8cce36222f 100644 --- a/jscomp/ext_string.ml +++ b/jscomp/ext_string.ml @@ -46,12 +46,15 @@ let starts_with s beg = let s_len = String.length s in beg_len <= s_len && (let i = ref 0 in - while !i < beg_len && s.[!i] = beg.[!i] do + while !i < beg_len + && String.unsafe_get s !i = + String.unsafe_get beg !i do incr i done; !i = beg_len ) + (* TODO: optimization *) let ends_with s beg = let s_finish = String.length s - 1 in @@ -164,3 +167,30 @@ let digits_of_str s ~offset x = +(* + {[ + starts_with_and_number "js_fn_mk_01" 0 "js_fn_mk_" = 1 ;; + starts_with_and_number "js_fn_run_02" 0 "js_fn_mk_" = -1 ;; + starts_with_and_number "js_fn_mk_03" 6 "mk_" = 3 ;; + starts_with_and_number "js_fn_mk_04" 6 "run_" = -1;; + starts_with_and_number "js_fn_run_04" 6 "run_" = 4;; + (starts_with_and_number "js_fn_run_04" 6 "run_" = 3) = false ;; + ]} +*) +let starts_with_and_number s ~offset beg = + let beg_len = String.length beg in + let s_len = String.length s in + let finish_delim = offset + beg_len in + + if finish_delim > s_len then -1 + else + let i = ref offset in + while !i < finish_delim + && String.unsafe_get s !i = + String.unsafe_get beg (!i - offset) do + incr i + done; + if !i = finish_delim then + digits_of_str ~offset:finish_delim s 2 + else + -1 diff --git a/jscomp/ext_string.mli b/jscomp/ext_string.mli index 28738697bf..706b82f302 100644 --- a/jscomp/ext_string.mli +++ b/jscomp/ext_string.mli @@ -49,3 +49,5 @@ val rfind : sub:string -> string -> int val tail_from : string -> int -> string val digits_of_str : string -> offset:int -> int -> int + +val starts_with_and_number : string -> offset:int -> string -> int diff --git a/jscomp/lam_compile.ml b/jscomp/lam_compile.ml index 860506c529..50c807e407 100644 --- a/jscomp/lam_compile.ml +++ b/jscomp/lam_compile.ml @@ -679,91 +679,123 @@ and let exp = E.or_ l_expr r_expr in Js_output.handle_block_return st should_return lam args_code exp end - | Lprim (Pccall {prim_name = - ( - "js_fn_mk_00" - | "js_fn_mk_01" - | "js_fn_mk_02" - | "js_fn_mk_03" - | "js_fn_mk_04" - | "js_fn_mk_05" - | "js_fn_mk_06" - | "js_fn_mk_07" - | "js_fn_mk_08" - | "js_fn_mk_09" - as name ) - }, [fn]) - -> - let arity = Ext_string.digits_of_str ~offset:9 (* String.length "js_fn_mk_" *) name 2 in - begin match fn with - | Lambda.Lfunction(kind,args, body) - -> - let len = List.length args in - if len = arity then - compile_lambda cxt fn - else if len > arity then - let first, rest = Ext_list.take arity args in - compile_lambda cxt (Lambda.Lfunction (kind, first, Lambda.Lfunction (kind, rest, body))) - else - compile_lambda cxt (Lam_util.eta_conversion arity Lam_util.default_apply_info fn [] ) - (* let extra_args = Ext_list.init (arity - len) (fun _ -> (Ident.create Literals.param)) in *) - (* let extra_lambdas = List.map (fun x -> Lambda.Lvar x) extra_args in *) - (* Lambda.Lfunction (kind, extra_args @ args , body ) *) - (*TODO: can be optimized ? - {[\ x y -> (\u -> body x) x y]} - {[\u x -> body x]} - rewrite rules - {[ - \x -> body - -- - \y (\x -> body ) y - ]} - {[\ x y -> (\a b c -> g a b c) x y]} - {[ \a b -> \c -> g a b c ]} - *) - | _ -> - compile_lambda cxt (Lam_util.eta_conversion arity Lam_util.default_apply_info fn [] ) - end (* TODO: check the arity of fn before wrapping it we need mark something that such eta-conversion can not be simplified in some cases *) - | Lprim (Pccall{prim_name = "js_debugger"; _}, - _) - -> - (* [%bs.debugger] guarantees that the expression does not matter + + | Lprim (prim, args_lambda) -> + let cont args_code exp = + Js_output.handle_block_return st should_return lam args_code exp in + begin match prim with + | Pccall {prim_name = "js_debugger"; _} + -> + (* [%bs.debugger] guarantees that the expression does not matter TODO: make it even safer *) - Js_output.handle_block_return st should_return lam [S.debugger] E.unit - | Lprim (prim, args_lambda) -> - begin + cont [S.debugger] E.unit + | Pccall {prim_name = name} + when Ext_string.starts_with name "js_fn_" + -> + let arity, kind = + let mk = Ext_string.starts_with_and_number name ~offset:6 "mk_" in + if mk < 0 then + let run = Ext_string.starts_with_and_number name ~offset:6 "run_" in + run , `Run + else mk, `Mk + in + + (* 1. prevent eta-conversion + by using [App_js_full] + 2. invariant: `external` declaration will guarantee + the function application is saturated + 3. we need a location for Pccall in the call site + *) + + if kind = `Run then + match args_lambda with + | fn :: rest -> + compile_lambda cxt @@ + Lambda.Lapply (fn, rest , + {apply_loc = Location.none; + apply_status = App_js_full}) + | _ -> assert false + else + begin match args_lambda with + | [fn] -> + if arity = 0 then + (* + Invariant: mk0 : (unit -> 'a0) -> 'a0 t + TODO: this case should be optimized, + we need check where we handle [arity=0] + as a special case -- + if we do an optimization before compiling + into lambda + *) + compile_lambda cxt + (Lfunction (Lambda.Curried, [], + Lambda.Lapply(fn, + [Lam_util.lam_unit], + Lam_util.default_apply_info + ))) + else + begin match fn with + | Lambda.Lfunction(kind,args, body) + -> + let len = List.length args in + if len = arity then + compile_lambda cxt fn + else if len > arity then + let first, rest = Ext_list.take arity args in + compile_lambda cxt + (Lambda.Lfunction + (kind, first, Lambda.Lfunction (kind, rest, body))) + else + compile_lambda cxt + (Lam_util.eta_conversion arity Lam_util.default_apply_info + fn [] ) + (* let extra_args = Ext_list.init (arity - len) (fun _ -> (Ident.create Literals.param)) in *) + (* let extra_lambdas = List.map (fun x -> Lambda.Lvar x) extra_args in *) + (* Lambda.Lfunction (kind, extra_args @ args , body ) *) + (*TODO: can be optimized ? + {[\ x y -> (\u -> body x) x y]} + {[\u x -> body x]} + rewrite rules + {[ + \x -> body + -- + \y (\x -> body ) y + ]} + {[\ x y -> (\a b c -> g a b c) x y]} + {[ \a b -> \c -> g a b c ]} + *) + | _ -> + compile_lambda cxt + (Lam_util.eta_conversion arity Lam_util.default_apply_info fn [] ) + end + | _ -> assert false + end + | _ -> let args_block, args_expr = - args_lambda - |> List.map (fun (x : Lambda.lambda) -> + Ext_list.split_map (fun (x : Lambda.lambda) -> match compile_lambda {cxt with st = NeedValue; should_return = False} x with | {block = a; value = Some b} -> a,b - | _ -> assert false ) - |> List.split + | _ -> assert false ) args_lambda + in let args_code = List.concat args_block in let exp = (* TODO: all can be done in [compile_primitive] *) Lam_compile_primitive.translate cxt prim args_expr in - Js_output.handle_block_return st should_return lam args_code exp + cont args_code exp end | Lsequence (l1,l2) -> let output_l1 = compile_lambda {cxt with st = EffectCall; should_return = False} l1 in let output_l2 = compile_lambda cxt l2 in - let result = output_l1 ++ output_l2 in - (* let () = *) - (* Ext_log.dwarn __LOC__ *) - (* "@ @[l1:%a@ js-l1(%d):%s@ l2:@ %a@ js-l2(%d):%s@ js-l:@ %s@]" *) - (* Printlambda.lambda l1 (List.length output_l1.block) (Js_output.to_string output_l1) *) - (* Printlambda.lambda l2 (List.length output_l2.block) (Js_output.to_string output_l2) *) - (* (Js_output.to_string result ) in *) - result + output_l1 ++ output_l2 + (* begin match cxt.st, cxt.should_return with *) diff --git a/jscomp/lam_util.ml b/jscomp/lam_util.ml index 053b2b2d9f..3359c88830 100644 --- a/jscomp/lam_util.ml +++ b/jscomp/lam_util.ml @@ -1,3 +1,4 @@ + (* BuckleScript compiler * Copyright (C) 2015-2016 Bloomberg Finance L.P. * @@ -313,9 +314,14 @@ let mk_apply_info ?(loc = Location.none) apply_status : Lambda.apply_info = { apply_loc = loc; apply_status } -let lam_true : Lambda.lambda = Lconst (Const_pointer ( 1, Pt_constructor "true")) +let lam_true : Lambda.lambda = + Lconst (Const_pointer ( 1, Pt_constructor "true")) + +let lam_false : Lambda.lambda = + Lconst (Const_pointer( 0, Pt_constructor "false")) -let lam_false : Lambda.lambda = Lconst (Const_pointer( 0, Pt_constructor "false")) +let lam_unit : Lambda.lambda = + Lconst (Const_pointer( 0, Pt_constructor "()")) let is_function (lam : Lambda.lambda) = match lam with diff --git a/jscomp/lam_util.mli b/jscomp/lam_util.mli index 13054209db..1af06d0ae4 100644 --- a/jscomp/lam_util.mli +++ b/jscomp/lam_util.mli @@ -61,6 +61,7 @@ val mk_apply_info : ?loc:Location.t -> Lambda.apply_status -> Lambda.apply_info val lam_true : Lambda.lambda val lam_false : Lambda.lambda +val lam_unit : Lambda.lambda val not_function : Lambda.lambda -> bool val is_function : Lambda.lambda -> bool diff --git a/jscomp/lib/js_fn.ml b/jscomp/lib/js_fn.ml index 4fc72d7fbc..bd4dfa1f99 100644 --- a/jscomp/lib/js_fn.ml +++ b/jscomp/lib/js_fn.ml @@ -31,42 +31,82 @@ *) -type 'a t +type + 'a t external mk0 : (unit -> 'a0) -> 'a0 t = "js_fn_mk_00" +external run0 : 'a0 t -> 'a0 = "js_fn_run_00" + external mk1 : ('a0 -> 'a1) -> ('a0 * 'a1) t = "js_fn_mk_01" +external run1 : ('a0 * 'a1) t -> 'a0 -> 'a1 = + "js_fn_run_01" + external mk2 : ('a0 -> 'a1 -> 'a2 ) -> ('a0 * 'a1 * 'a2) t = "js_fn_mk_02" -external mk3 : ('a0 -> 'a1 -> 'a2 -> 'a3 ) -> ('a0 * 'a1 * 'a2 * 'a3) t = +external run2 : ('a0 * 'a1 * 'a2 )t -> 'a0 -> 'a1 -> 'a2 = + "js_fn_run_02" + +external mk3 : + ('a0 -> 'a1 -> 'a2 -> 'a3 ) -> ('a0 * 'a1 * 'a2 * 'a3) t = "js_fn_mk_03" -external mk4 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 ) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t = +external run3 : + ('a0 * 'a1 * 'a2 * 'a3) t -> 'a0 -> 'a1 -> 'a2 -> 'a3 = + "js_fn_run_03" + +external mk4 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 ) + -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t = "js_fn_mk_04" -external mk5 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 ) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t = +external run4 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t -> + 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 = + "js_fn_run_04" + +external mk5 : + ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 ) -> + ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t = "js_fn_mk_05" +external run5 : + ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t + -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 = + "js_fn_run_05" external mk6 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6) t = "js_fn_mk_06" +external run6 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6) t + -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 = + "js_fn_run_06" external mk7 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 ) t = "js_fn_mk_07" +external run7 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 ) t + -> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 = + "js_fn_run_07" external mk8 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 ) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 ) t = "js_fn_mk_08" +external run8 : + ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 ) t -> + 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 + = + "js_fn_run_08" -external mk9 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9) -> +external mk9 : + ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9) -> ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 ) t = "js_fn_mk_09" +external run9 : + ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 ) t -> + 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 = + "js_fn_run_09" diff --git a/jscomp/test/.depend b/jscomp/test/.depend index 1a9bc89be6..3b0887b1f5 100644 --- a/jscomp/test/.depend +++ b/jscomp/test/.depend @@ -128,6 +128,8 @@ equal_test.cmo : equal_test.cmx : es6_module_test.cmo : mt.cmi ../stdlib/list.cmi es6_module_test.cmx : mt.cmx ../stdlib/list.cmx +event_ffi.cmo : ../lib/js_fn.cmo ../lib/js.cmo +event_ffi.cmx : ../lib/js_fn.cmx ../lib/js.cmx exception_raise_test.cmo : mt.cmi exception_raise_test.cmx : mt.cmx ext_array.cmo : ../stdlib/list.cmi ../stdlib/array.cmi @@ -666,6 +668,8 @@ equal_test.cmo : equal_test.cmj : es6_module_test.cmo : mt.cmi ../stdlib/list.cmi es6_module_test.cmj : mt.cmj ../stdlib/list.cmj +event_ffi.cmo : ../lib/js_fn.cmo ../lib/js.cmo +event_ffi.cmj : ../lib/js_fn.cmj ../lib/js.cmj exception_raise_test.cmo : mt.cmi exception_raise_test.cmj : mt.cmj ext_array.cmo : ../stdlib/list.cmi ../stdlib/array.cmi diff --git a/jscomp/test/event_ffi.js b/jscomp/test/event_ffi.js new file mode 100644 index 0000000000..b5ccf26aa0 --- /dev/null +++ b/jscomp/test/event_ffi.js @@ -0,0 +1,103 @@ +// Generated CODE, PLEASE EDIT WITH CARE +'use strict'; + +var Caml_primitive = require("../runtime/caml_primitive"); +var Caml_curry = require("../runtime/caml_curry"); + +function h0(x) { + return x(); +} + +function h00(x) { + return Caml_curry.app1(x(), /* () */0); +} + +function h1(x) { + return function (param) { + return x(param); + }; +} + +function h10(x) { + return x(3); +} + +function h30(x) { + return function (param) { + return x(3, 3, param); + }; +} + +function h33(x) { + return x(1, 2, 3); +} + +function h34(x) { + return Caml_curry.app1(x(1, 2, 3), 4); +} + +function ocaml_run(param, param$1) { + var x = 1; + var y = param; + var z = param$1; + return (x + y | 0) + z | 0; +} + +function a0() { + return Caml_curry.app1(function () { + console.log("hi"); + return /* () */0; + }, /* () */0); +} + +function a1(x) { + return x; +} + +function a2(x, y) { + return x + y | 0; +} + +function a3(x, y, z) { + return (x + y | 0) + z | 0; +} + +function a4(param, param$1, param$2, param$3) { + return Caml_curry.app4(function (x, y, z) { + var u = (Caml_primitive.imul(x, x) + Caml_primitive.imul(y, y) | 0) + Caml_primitive.imul(z, z) | 0; + return function (d) { + return u + d | 0; + }; + }, param, param$1, param$2, param$3); +} + +function a44(x, y, z, d) { + var u = (Caml_primitive.imul(x, x) + Caml_primitive.imul(y, y) | 0) + Caml_primitive.imul(z, z) | 0; + return u + d | 0; +} + +function b44(x, y, z, d) { + return /* tuple */[ + x, + y, + z, + d + ]; +} + +exports.h0 = h0; +exports.h00 = h00; +exports.h1 = h1; +exports.h10 = h10; +exports.h30 = h30; +exports.h33 = h33; +exports.h34 = h34; +exports.ocaml_run = ocaml_run; +exports.a0 = a0; +exports.a1 = a1; +exports.a2 = a2; +exports.a3 = a3; +exports.a4 = a4; +exports.a44 = a44; +exports.b44 = b44; +/* partial_arg Not a pure module */ diff --git a/jscomp/test/event_ffi.ml b/jscomp/test/event_ffi.ml new file mode 100644 index 0000000000..b4deea2b37 --- /dev/null +++ b/jscomp/test/event_ffi.ml @@ -0,0 +1,63 @@ + + + +(* +type process + +external on : process -> + [ + `beforeExit + | `exit + ] -> unit Js_fn.t -> unit = "on" [@@bs.send] + + +external p : process = "process" [@@bs.val] + + +external on_hi : process -> + [ + `hello + | `xx + ] -> (unit*unit) Js_fn.t -> unit = "on" [@@bs.send] + +type 'a t + +external (!) : 'a t -> 'a = "identity" + +let f x = + !x # hey 3 + !x # v + +let () = + on p `exit (Js_fn.mk0 (fun _ -> prerr_endline "hello world")); + on_hi p `xx (Js_fn.mk1 (fun _ -> prerr_endline "hello world")) + +*) + +let h0 x = Js_fn.run0 x +(* {[ + function h0 (x){ + return x () + } + ]} +*) +let h00 x = Js_fn.run0 x () + +let h1 x = Js_fn.run1 x +let h10 x = Js_fn.run1 x 3 + +let h30 x = Js_fn.run3 x 3 3 +let h33 x = Js_fn.run3 x 1 2 3 +let h34 x = Js_fn.run3 x 1 2 3 4 + + +let ocaml_run = Js_fn.run3 (Js_fn.mk3 (fun x y z -> x + y + z)) 1 + +let a0 = Js_fn.mk0 (fun _ -> Js.log "hi") +let a1 = Js_fn.mk1 (fun x -> x ) +let a2 = Js_fn.mk2 (fun x y -> x + y) +let a3 = Js_fn.mk3 (fun x y z -> x + y + z ) +let a4 = Js_fn.mk4 (fun x y z -> let u = x * x + y * y + z * z in fun d -> u + d) + +let a44 = Js_fn.mk4 (fun x y z d -> let u = x * x + y * y + z * z in u + d) + +let b44 = Js_fn.mk4 (fun x y z d -> (x,y,z,d)) diff --git a/jscomp/test/ext_string.js b/jscomp/test/ext_string.js index ffdf94ec4d..96ca21da7d 100644 --- a/jscomp/test/ext_string.js +++ b/jscomp/test/ext_string.js @@ -301,18 +301,40 @@ function digits_of_str(s, offset, x) { }; } -exports.split_by = split_by; -exports.split = split; -exports.starts_with = starts_with; -exports.ends_with = ends_with; -exports.escaped = escaped; -exports.for_all = for_all; -exports.is_empty = is_empty; -exports.repeat = repeat; -exports.equal = equal; -exports._is_sub = _is_sub; -exports.find = find; -exports.rfind = rfind; -exports.tail_from = tail_from; -exports.digits_of_str = digits_of_str; +function starts_with_and_number(s, offset, beg) { + var beg_len = beg.length; + var s_len = s.length; + var finish_delim = offset + beg_len | 0; + if (finish_delim > s_len) { + return -1; + } + else { + var i = offset; + while(i < finish_delim && s[i] === beg[i - offset | 0]) { + i = i + 1 | 0; + }; + if (i === finish_delim) { + return digits_of_str(s, finish_delim, 2); + } + else { + return -1; + } + } +} + +exports.split_by = split_by; +exports.split = split; +exports.starts_with = starts_with; +exports.ends_with = ends_with; +exports.escaped = escaped; +exports.for_all = for_all; +exports.is_empty = is_empty; +exports.repeat = repeat; +exports.equal = equal; +exports._is_sub = _is_sub; +exports.find = find; +exports.rfind = rfind; +exports.tail_from = tail_from; +exports.digits_of_str = digits_of_str; +exports.starts_with_and_number = starts_with_and_number; /* No side effect */ diff --git a/jscomp/test/ffi_arity_test.js b/jscomp/test/ffi_arity_test.js index 6cd7bdff38..1ff1aef5b4 100644 --- a/jscomp/test/ffi_arity_test.js +++ b/jscomp/test/ffi_arity_test.js @@ -42,9 +42,15 @@ var hh = /* array */[ return parseInt(prim); }); +function u() { + return Caml_curry.app1(function () { + return 3; + }, /* () */0); +} + Mt.from_pair_suites("ffi_arity_test.ml", /* :: */[ /* tuple */[ - 'File "ffi_arity_test.ml", line 21, characters 4-11', + 'File "ffi_arity_test.ml", line 23, characters 4-11', function () { return /* Eq */{ 0: v, @@ -60,7 +66,7 @@ Mt.from_pair_suites("ffi_arity_test.ml", /* :: */[ ], /* :: */[ /* tuple */[ - 'File "ffi_arity_test.ml", line 22, characters 4-11', + 'File "ffi_arity_test.ml", line 24, characters 4-11', function () { return /* Eq */{ 0: vv, @@ -76,7 +82,7 @@ Mt.from_pair_suites("ffi_arity_test.ml", /* :: */[ ], /* :: */[ /* tuple */[ - 'File "ffi_arity_test.ml", line 23, characters 4-11', + 'File "ffi_arity_test.ml", line 25, characters 4-11', function () { return /* Eq */{ 0: hh, @@ -92,7 +98,7 @@ Mt.from_pair_suites("ffi_arity_test.ml", /* :: */[ ], /* :: */[ /* tuple */[ - 'File "ffi_arity_test.ml", line 24, characters 4-11', + 'File "ffi_arity_test.ml", line 26, characters 4-11', function () { return /* Eq */{ 0: /* int array */[ @@ -118,7 +124,7 @@ Mt.from_pair_suites("ffi_arity_test.ml", /* :: */[ ], /* :: */[ /* tuple */[ - 'File "ffi_arity_test.ml", line 29, characters 4-11', + 'File "ffi_arity_test.ml", line 31, characters 4-11', function () { return /* Eq */{ 0: /* int array */[ @@ -154,4 +160,5 @@ exports.f = f; exports.v = v; exports.vv = vv; exports.hh = hh; +exports.u = u; /* v Not a pure module */ diff --git a/jscomp/test/ffi_arity_test.ml b/jscomp/test/ffi_arity_test.ml index 7295ae8596..cb09074d06 100644 --- a/jscomp/test/ffi_arity_test.ml +++ b/jscomp/test/ffi_arity_test.ml @@ -17,6 +17,8 @@ let vv = mapi [|1;2;3 |] (Js_fn.mk2 (+)) let hh = map [|"1";"2";"3"|] (Js_fn.mk1 parseInt) +let u = Js_fn.mk0 (fun _ -> 3) + ;; Mt.from_pair_suites __FILE__ Mt.[ __LOC__, (fun _ -> Eq(v, [|0; 1; 4 |] )); __LOC__, (fun _ -> Eq(vv, [|1;3;5|])); diff --git a/jscomp/test/test.mllib b/jscomp/test/test.mllib index 0bb347bd06..2e77828450 100644 --- a/jscomp/test/test.mllib +++ b/jscomp/test/test.mllib @@ -1,3 +1,4 @@ + a test_ari test_export2 @@ -240,4 +241,8 @@ class7_test class8_test class_repr -mt_global \ No newline at end of file + +mt_global + +event_ffi +