-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Recursive Modules on ocaml < 4.13 #1485
Conversation
@@ -66,3 +66,25 @@ end | |||
let () = | |||
List.iter (fun x -> x#go) | |||
[new Foo.cls; Foo.M.foo(); Lazy.force Foo.M.bar] | |||
|
|||
module rec Even : sig val is: int -> bool end = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to keep the directory tests-ocaml
as close as possible to the testsuite/tests
directory from ocaml repo.
Can you move the test in compiler/tests-jsoo/test_rec_mod.ml
?
I'll try to document that the purpose of the various test directories
Running the test in compiler/tests-jsoo/test_rec_mod.ml //Provides: caml_update_dummy
function caml_update_dummy (x, y) {
- if( typeof y==="function" ) { x.fun = y; return 0; }
if( y.fun ) { x.fun = y.fun; return 0; }
+ if( typeof y==="function" ) { x.fun = y; return 0; }
var i = y.length; while (i--) x[i] = y[i]; return 0;
} |
LGMT, I left small comments. |
Here is a commit allowing to run some test with ocaml 4.12. There are already showing the issue you're fixing. Fill tree to include this commit in your branch. |let%expect_test _ =
| (try print_int (M1.f 3) with e -> print_endline @@ Printexc.to_string e);
-| [%expect {| 2 |}];
+| [%expect {|
+| function(){
+| var
+| extra_args = arguments.length == 0 ? 1 : arguments.length,
+| nargs = new Array(args.length + extra_args);
+| for(var i = 0; i < args.length; i++) nargs[i] = args[i];
+| for(var i = 0; i < arguments.length; i++)
+| nargs[args.length + i] = arguments[i];
+| return caml_call_gen(f, nargs);
+| } |}];
-| (try print_int (M1.g 3) with e -> print_endline @@ Printexc.to_string e);
-| [%expect {| 2 |}];
+| (try print_int (M1.g 3) with e -> print_endline @@ Printexc.to_string e);
+| [%expect {|
+| function(){
+| var
+| extra_args = arguments.length == 0 ? 1 : arguments.length,
+| nargs = new Array(args.length + extra_args);
+| for(var i = 0; i < args.length; i++) nargs[i] = args[i];
+| for(var i = 0; i < arguments.length; i++)
+| nargs[args.length + i] = arguments[i];
+| return caml_call_gen(f, nargs);
+| } |}];
-| (try print_int (M1.h 3) with e -> print_endline @@ Printexc.to_string e);
-| [%expect {| 2 |}]
+| (try print_int (M1.h 3) with e -> print_endline @@ Printexc.to_string e);
+| [%expect {|
+| function(){
+| var
+| extra_args = arguments.length == 0 ? 1 : arguments.length,
+| nargs = new Array(args.length + extra_args);
+| for(var i = 0; i < args.length; i++) nargs[i] = args[i];
+| for(var i = 0; i < arguments.length; i++)
+| nargs[args.length + i] = arguments[i];
+| return caml_call_gen(f, nargs);
+| } |}]
|
|module rec Odd : sig
| val odd : int -> bool
|end = struct
| let odd x = if x = 0 then false else Even.even (pred x)
|end
|
|and Even : sig
| val even : int -> bool
|end = struct
| let even x = if x = 0 then true else Odd.odd (pred x)
|end
|
|let%expect_test _ =
| Printf.printf "%b" (Even.even 1000);
| [%expect {| true |}];
| Printf.printf "%b" (Odd.odd 1000);
-| [%expect {| false |}]
+| [%expect {| true |}] |
This reverts commit 3f52c54.
Co-authored-by: Hugo Heuzard <hugo.heuzard@gmail.com>
I still have:
But I guess this is expected on 4.12, right ? |
Yes, this is expected. |
Merged, thanks again |
Thank you ! |
…s_of_ocaml-ppx_deriving_json, js_of_ocaml-ppx, js_of_ocaml-lwt and js_of_ocaml-compiler (5.4.0) CHANGES: ## Bug fixes * Runtime: Fix recursive modules on ocaml < 4.13 (ocsigen/js_of_ocaml#1485) * Runtime: fix hashing of NaN (ocsigen/js_of_ocaml#1475) * Runtime: float rounding should resolve tie away from zero (ocsigen/js_of_ocaml#1475) * Runtime: fix Gc.stat, Gc.quick_stat, Gc.get (ocsigen/js_of_ocaml#1475) * Compiler: fix some miscompilation, probably introduced in jsoo 5.0.0, revealed by OCaml 5.0
…s_of_ocaml-ppx_deriving_json, js_of_ocaml-ppx, js_of_ocaml-lwt and js_of_ocaml-compiler (5.4.0) CHANGES: ## Bug fixes * Runtime: Fix recursive modules on ocaml < 4.13 (ocsigen/js_of_ocaml#1485) * Runtime: fix hashing of NaN (ocsigen/js_of_ocaml#1475) * Runtime: float rounding should resolve tie away from zero (ocsigen/js_of_ocaml#1475) * Runtime: fix Gc.stat, Gc.quick_stat, Gc.get (ocsigen/js_of_ocaml#1475) * Compiler: fix some miscompilation, probably introduced in jsoo 5.0.0, revealed by OCaml 5.0
Description
The CI of gen_js_api is failing for version of ocaml < 4.13 on some tests involving recursive module.
This can basically be reproduced by running on ocaml 4.12.1:
The "Even.is" is not even a function (as shown by a debugger); it is an object with a single
fun
property and it is not callable.Since PR #1389,
caml_call_gen
is no longer checking for the presence of ".fun".Fix Proposal
We could use
caml_alloc_dummy_infix
to allocate the dummy function.