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

OCaml 5.0 support #1553

Closed
edwintorok opened this issue Dec 26, 2022 · 1 comment
Closed

OCaml 5.0 support #1553

edwintorok opened this issue Dec 26, 2022 · 1 comment

Comments

@edwintorok
Copy link
Contributor

I got this error from ocaml-lsp-server (which vendors merlin):

[ERROR][2022-12-26 22:14:37] .../vim/lsp/rpc.lua:733	"rpc"	"ocamllsp"	"stderr"	'detached: /-----------------------------------------------------------------------\n| Internal error: Uncaught exception.\n| Not_found\n| Raised at Merlin_utils__Std.Option.get in file "ocaml-lsp-server/vendor/merlin/src/utils/std.ml" (inlined), line 301, characters 14-29\n| Called from Ocaml_typing__Magic_numbers.Cmi.report_error in file "ocaml-lsp-server/vendor/merlin/src/ocaml/typing/magic_numbers.ml", line 59, characters 10-64\n| Called from Stdlib__Format.output_acc in file "format.ml", line 1360, characters 4-20\n| Called from Stdlib__Format.kasprintf.k in file "format.ml", line 1464, characters 4-22\n| Called from Ocaml_lsp_server__Diagnostics.merlin_diagnostics.(fun).make_message in file "ocaml-lsp-server/src/diagnostics.ml", line 307, characters 30-60\n| Called from Ocaml_lsp_server__Diagnostics.merlin_diagnostics.(fun) in file "ocaml-lsp-server/src/diagnostics.ml", line 309, characters 30-63\n| Called from Stdlib__List.rev_map.rmap_f in file "list.ml", line 103, characters 22-25\n| Called from Ocaml_lsp_server__Diagnostics.merlin_diagnostics.(fun) in file "ocaml-lsp-server/src/diagnostics.ml", line 298, characters 12-1023\n| Called from Merlin_utils__Std.let_ref in file "ocaml-lsp-server/vendor/merlin/src/utils/std.ml", line 686, characters 8-12\n| Re-raised at Merlin_utils__Std.let_ref in file "ocaml-lsp-server/vendor/merlin/src/utils/std.ml", line 688, characters 30-39\n| Called from Merlin_utils__Misc.try_finally in file "ocaml-lsp-server/vendor/merlin/src/utils/misc.ml", line 45, characters 8-15\n| Re-raised at Merlin_utils__Misc.try_finally in file "ocaml-lsp-server/vendor/merlin/src/utils/misc.ml", line 62, characters 10-24\n| Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15\n| Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52\n| Called from Merlin_kernel__Mocaml.with_state in file "ocaml-lsp-server/vendor/merlin/src/kernel/mocaml.ml", line 18, characters 8-38\n| Re-raised at Merlin_kernel__Mocaml.with_state in file "ocaml-lsp-server/vendor/merlin/src/kernel/mocaml.ml", line 20, characters 42-53\n| Called from Ocaml_lsp_server__Document.Single_pipeline.use.(fun) in file "ocaml-lsp-server/src/document.ml", line 153, characters 22-77\n| Called from Stdune__Exn_with_backtrace.try_with in file "otherlibs/stdune/exn_with_backtrace.ml", line 9, characters 8-12\n| Re-raised at Stdune__Exn.raise_with_backtrace in file "otherlibs/stdune/exn.ml" (inlined), line 36, characters 27-56\n| Called from Stdune__Exn_with_backtrace.reraise in file "otherlibs/stdune/exn_with_backtrace.ml", line 18, characters 33-71\n| Called from Fiber__Core.O.(>>|).(fun) in file "src/fiber/core.ml", line 250, characters 36-41\n| Called from Fiber__Scheduler.exec in file "src/fiber/scheduler.ml", line 73, characters 8-11\n\\-----------------------------------------------------------------------\n\n'

I can't reproduce the error anymore (even if I switch between 4.14 and 5.0) but looking at the stacktrace the following should fix this:

diff --git a/src/ocaml/typing/magic_numbers.ml b/src/ocaml/typing/magic_numbers.ml
index 386f87993..ef7aade20 100644
--- a/src/ocaml/typing/magic_numbers.ml
+++ b/src/ocaml/typing/magic_numbers.ml
@@ -22,6 +22,7 @@ module Cmi = struct
     | "Caml1999I029" -> Some "4.12"
     | "Caml1999I030" -> Some "4.13"
     | "Caml1999I031" -> Some "4.14"
+    | "Caml1999I032" -> Some "5.0"
     | _ -> None
 
   open Format

However the other 'bump magic number' commits I looked at also bumped magic numbers elsewhere, should I just open a PR and bump the magic numbers like done in the other commits, or is there anything else that needs to be done for 5.0 support?

edwintorok added a commit to edwintorok/merlin that referenced this issue Dec 26, 2022
And add an assertion that we can recognize our own magic number that we
got compiled with.

Fixes ocaml#1553

Signed-off-by: Edwin Török <[email protected]>
edwintorok added a commit to edwintorok/merlin that referenced this issue Dec 26, 2022
And add an assertion that we can recognize our own magic number that we
got compiled with.

Fixes ocaml#1553

Signed-off-by: Edwin Török <[email protected]>
@edwintorok
Copy link
Contributor Author

Ah I see now, the 5.0 support is on the 500 branch, not master, which has indeed bumped some of the magic numbers but not all. Opened a PR to add the missing one, and an assertion to check that merlin can recognize its own magic number it got compiled with.

voodoos added a commit to voodoos/opam-repository that referenced this issue Feb 24, 2023
CHANGES:

Fri Feb 24 16:55:42 CEST 2023

  + merlin binary
    - Recognize OCaml 5.0 cmi magic number in compiler version mismatch message
      (ocaml/merlin#1554, fixes ocaml/merlin#1553)
    - Upgrade Merlin from the RC2 to the stable 5.0.0 compiler release (ocaml/merlin#1559,
      fixes ocaml/merlin#1558)
    - Improve type-enclosing behaviour when used on records' labels (ocaml/merlin#1565,
      fixes ocaml/merlin#1564)
    - Restore compatibility with the compiler's command line by accepting the
      `-safe-string` flag as a no-op instead of rejecting it (ocaml/merlin#1544, fixes
      ocaml/merlin#1518)
    - Traverse aliases when jumping to declaration. This matches
      jump-to-definition's behavior (ocaml/merlin#1563)
    - Improve locate's behavior in various ill-typed expressions (ocaml/merlin#1546, fixes
      ocaml/merlin#1567 and partially ocaml/merlin#1543)
    - Correctly traverse patterns when looking for docs in the typedtree (ocaml/merlin#1572)
    - Get documentation when the declaration or definition is selected (ocaml/merlin#1542,
      fixes ocaml/merlin#1540)
    - On Windows, change to a harmless directory when launching server to avoid
      locking down current directory (ocaml/merlin#1569, fixes ocaml/merlin#1474)
  + editor modes
    - emacs: Fix misuse of `eq` comparison (ocaml/merlin#1549, @mattiase)
    - emacs: xref works from context menus; better highlighting of xref matches;
      xref recognises operators and binding operators at the cursor position;
      bad locations are filtered out (ocaml/merlin#1385, fixes ocaml/merlin#1410, @mattiase)
  + test suite
    - Add a test for incorrect alert defaults (ocaml/merlin#1559)
    - Add multiple tests for locate over ill-typed expressions (ocaml/merlin#1546)
    - Add non-regression tests for other fixes in this release
voodoos added a commit to voodoos/opam-repository that referenced this issue Feb 24, 2023
CHANGES:

Fri Feb 24 16:55:42 CEST 2023

  + merlin binary
    - Recognize OCaml 5.0 cmi magic number in compiler version mismatch message
      (ocaml/merlin#1554, fixes ocaml/merlin#1553)
    - Upgrade Merlin from the RC2 to the stable 5.0.0 compiler release (ocaml/merlin#1559,
      fixes ocaml/merlin#1558)
    - Improve type-enclosing behaviour when used on records' labels (ocaml/merlin#1565,
      fixes ocaml/merlin#1564)
    - Restore compatibility with the compiler's command line by accepting the
      `-safe-string` flag as a no-op instead of rejecting it (ocaml/merlin#1544, fixes
      ocaml/merlin#1518)
    - Traverse aliases when jumping to declaration. This matches
      jump-to-definition's behavior (ocaml/merlin#1563)
    - Improve locate's behavior in various ill-typed expressions (ocaml/merlin#1546, fixes
      ocaml/merlin#1567 and partially ocaml/merlin#1543)
    - Correctly traverse patterns when looking for docs in the typedtree (ocaml/merlin#1572)
    - Get documentation when the declaration or definition is selected (ocaml/merlin#1542,
      fixes ocaml/merlin#1540)
    - On Windows, change to a harmless directory when launching server to avoid
      locking down current directory (ocaml/merlin#1569, fixes ocaml/merlin#1474)
  + editor modes
    - emacs: Fix misuse of `eq` comparison (ocaml/merlin#1549, @mattiase)
    - emacs: xref works from context menus; better highlighting of xref matches;
      xref recognises operators and binding operators at the cursor position;
      bad locations are filtered out (ocaml/merlin#1385, fixes ocaml/merlin#1410, @mattiase)
  + test suite
    - Add a test for incorrect alert defaults (ocaml/merlin#1559)
    - Add multiple tests for locate over ill-typed expressions (ocaml/merlin#1546)
    - Add non-regression tests for other fixes in this release
@voodoos voodoos closed this as completed Mar 9, 2023
voodoos pushed a commit to voodoos/merlin that referenced this issue May 2, 2024
And add an assertion that we can recognize our own magic number that we
got compiled with.

Fixes ocaml#1553

Signed-off-by: Edwin Török <[email protected]>
voodoos pushed a commit to voodoos/merlin that referenced this issue May 2, 2024
And add an assertion that we can recognize our own magic number that we
got compiled with.

Fixes ocaml#1553

Signed-off-by: Edwin Török <[email protected]>
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

No branches or pull requests

2 participants