Skip to content
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

[WIP] upgrade to OCaml 5 #199

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

[WIP] upgrade to OCaml 5 #199

wants to merge 7 commits into from

Conversation

kimmywork
Copy link

No description provided.

@kimmywork kimmywork closed this Mar 21, 2023
@kimmywork kimmywork changed the title compile passed [WIP] upgrade to OCaml 5 Mar 21, 2023
@kimmywork kimmywork reopened this Mar 21, 2023
@kimmywork
Copy link
Author

Hey @akabe
I've tried to upgrade ocaml version to 5.0.0, passed the compile but there are few test cases still failing.

One of the reasons should be following deprecations:

Alert ocaml_deprecated_auto_include:
OCaml's lib directory layout changed in 5.0. The str subdirectory has been
automatically added to the search path, but you should add -I +str to the
command-line to silence this alert (e.g. by adding str to the list of
libraries in your dune file, or adding use_str to your _tags file for
ocamlbuild, or using -package str for ocamlfind).

Affected test cases:

  • Evaluation.eval.directive which loads str.cma
  • Merlin.complete which loads unix.cma

Another reason is related to the toplevel change, and it doesn't accept #require directives. Affected test cases

  • Evaluation.eval.ppx which #require "ppx_deriving.show"

I've commented out these test cases and need your help on the details to fix these for OCaml 5.

Copy link
Owner

@akabe akabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kimmywork Thank you for creating a patch for OCaml 5. OCaml 5 had many disruptive changes and I skipped responding to them. I suggest ideas for solving the issue of Test_evaluation.test__directive and merlin.

jupyter.opam Outdated
@@ -17,7 +17,7 @@ build: [
[ "dune" "build" "-p" name "-j" jobs ]
]
depends: [
"ocaml" {>= "4.10.0" & < "4.15"}
"ocaml" {(>= "4.10.0" & < "4.15") | (>= "5.0.0")}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget updating the restriction of ocaml versions. I'd like to suggest

"ocaml" {>= "4.10.0"}

because ocaml-jupyter kernel now supports 4.15.
cf. jupyter.2.8.2/opam

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -61,11 +61,11 @@ let test__multiple_phrases ctxt =
assert_equal ~ctxt ~printer:[%show: status] SHELL_OK status ;
assert_equal ~ctxt ~printer:[%show: reply list] expected actual

let test__directive ctxt =
(* let test__directive ctxt =
let status, actual = eval "#load \"str.cma\" ;; Str.regexp \".*\"" in
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case only checks whether a directive works fine, or not. We can check an other directive, not #load.
In my environment, this patch works.

-(* let test__directive ctxt =
-  let status, actual = eval "#load \"str.cma\" ;; Str.regexp \".*\"" in
+let test__directive ctxt =
+  let status, actual = eval "#require \"str\" ;; Str.regexp \".*\"" in
   let expected = [iopub_success ~count:0 "- : Str.regexp = <abstr>\n"] in

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -163,7 +163,8 @@ let test_complete ctxt =
];
} in
let actual = complete merlin code ~pos:15 in
require expected actual ~msg:"module" ;
require expected actual ~msg:"module"
(* ;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out lines are not important checks. Could you remove them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -1,3 +1,3 @@
(-w A-4-31-33-34-39-41-42-43-44-45-48-49-50-58-66
-safe-string -strict-sequence -strict-formats
-safe-string -strict-sequence -strict-formats
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you delete a space at the end of line?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@akabe
Copy link
Owner

akabe commented Mar 26, 2023

The issue of ppx is hard maybe. I have not yet been able to find a solution.

In the official OCaml 5, #require "ppx_deriving.show" prints ppx_deriving: package:ppx_deriving.show: option added at the last, but ocaml-jupyter (OCaml 5) does not.

$ ocaml
OCaml version 5.0.0

# #require "ppx_deriving.show";;
/Users/akabe/.opam/5.0.0/lib/result: added to search path
/Users/akabe/.opam/5.0.0/lib/result/result.cma: loaded
/Users/akabe/.opam/5.0.0/lib/ppx_deriving/runtime: added to search path
/Users/akabe/.opam/5.0.0/lib/ppx_deriving/runtime/ppx_deriving_runtime.cma: loaded
/Users/akabe/.opam/5.0.0/lib/ppx_deriving: added to search path
/Users/akabe/.opam/5.0.0/lib/ppx_deriving/./ppx_deriving: activated
/Users/akabe/.opam/5.0.0/lib/ppx_deriving/show: added to search path
ppx_deriving: package:ppx_deriving.show: option added

スクリーンショット 2023-03-26 15 51 10

@akabe
Copy link
Owner

akabe commented Mar 26, 2023

CI fails due to code format. Try make format.

@kimmywork
Copy link
Author

In the official OCaml 5, #require "ppx_deriving.show" prints ppx_deriving: package:ppx_deriving.show: option added at the last, but ocaml-jupyter (OCaml 5) does not.

Same on my side.

I've fixed the code in your comments above, but just found another issue when running make test.
It seems that all tests passed, but make test still got an error.

Full output:

  ocaml-jupyter git:(ocaml-5) ✗ make test
opam exec -- dune runtest
File "src/completor/merlin.ml", line 85, characters 4-32:
85 |     notifications : string list;
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 69 [unused-field]: record field notifications is never read.
(However, this field is used to build or mutate values.)
File "tests/repl/eval_util.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/notebook/test_bench.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/completor/test_merlin.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/kernel/fixture.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/kernel/test_zmq_channel.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/completor/test_completor.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/repl/test_evaluation.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/kernel/test_hmac.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/repl/test_process.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/kernel/test_message_channel.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/notebook/test_process.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/kernel/test_kernel.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
File "tests/notebook/test_notebook.pp.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
...
Ran: 3 tests in: 0.12 seconds.
OK
........
Ran: 8 tests in: 0.04 seconds.
OK
....................
Ran: 20 tests in: 0.72 seconds.
OK
File "tests/repl/dune", line 13, characters 0-304:
13 | (alias
14 |  (name   runtest)
15 |  (deps   test_evaluation.bc
16 |          test_process.bc
17 |          ../fixtures/ocamlinit.ml
18 |          ../fixtures/file.bin)
19 |  (action
20 |   (chdir %{project_root}/tests
21 |          (progn
22 |            (run %{dep:test_evaluation.bc})
23 |            (run %{dep:test_process.bc} -runner sequential)))))
...........
Ran: 11 tests in: 0.42 seconds.
OK
make: *** [unit-test] Error 1

@kimmywork
Copy link
Author

I see, all test_evaluation.bc cases passed but got a segment fault result. all test_process.bc cases failed when closing repl, the subprocess status is Killed by signal -10.

@akabe
Copy link
Owner

akabe commented Apr 3, 2023

@kimmywork Thanks for fixing. I am also aware of the same issue. As it is likely a deep-rooted problem, I anticipate that it will take some time to find a solution, but I will continue my investigation as well. I have been a bit busy lately, so please give me some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants