Skip to content

OCaml 5.0 support #1553

@edwintorok

Description

@edwintorok

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions