From 5e4c6bdea7de6aec77178a3ad2838ce557c71a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Fri, 10 Jan 2025 16:58:32 +0100 Subject: [PATCH 1/3] Show issue with completions type printing --- tests/test-dirs/completion/issue-lsp-503.t | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/test-dirs/completion/issue-lsp-503.t diff --git a/tests/test-dirs/completion/issue-lsp-503.t b/tests/test-dirs/completion/issue-lsp-503.t new file mode 100644 index 000000000..a681f7ac4 --- /dev/null +++ b/tests/test-dirs/completion/issue-lsp-503.t @@ -0,0 +1,39 @@ + + $ cat >test.ml <<'EOF' + > [1;2]|>List.ma + > EOF + +We complete the name of the object + + $ $MERLIN single complete-prefix -position 1:14 -prefix "List.ma" \ + > -filename test.ml < test.ml + { + "class": "return", + "value": { + "entries": [ + { + "name": "map", + "kind": "Value", + "desc": "('a1 -> 'b1) -> 'a1 list -> 'b1 list", + "info": "", + "deprecated": false + }, + { + "name": "mapi", + "kind": "Value", + "desc": "(int -> 'a0 -> 'b0) -> 'a0 list -> 'b0 list", + "info": "", + "deprecated": false + }, + { + "name": "map2", + "kind": "Value", + "desc": "('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list", + "info": "", + "deprecated": false + } + ], + "context": null + }, + "notifications": [] + } From 6b7ace88f0c74f86a11ffa197ddbace6128005a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Fri, 10 Jan 2025 17:02:20 +0100 Subject: [PATCH 2/3] Fix the issue by preparing texp for printing --- src/analysis/completion.ml | 5 +++-- src/analysis/type_utils.ml | 4 ++++ src/analysis/type_utils.mli | 2 ++ tests/test-dirs/completion/issue-lsp-503.t | 4 ++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/analysis/completion.ml b/src/analysis/completion.ml index 53df7869b..8cd228923 100644 --- a/src/analysis/completion.ml +++ b/src/analysis/completion.ml @@ -57,12 +57,13 @@ let raw_info_printer : raw_info -> _ = function (Out_sig_item (Out_type.tree_of_type_declaration id tdecl Types.Trec_first)) | `Type_scheme te -> - `Print (Out_type (Out_type.tree_of_typexp Type_scheme te)) + `Print (Out_type (Type_utils.Printtyp.tree_of_typ_scheme te)) | `Variant (label, arg) -> begin match arg with | None -> `String label | Some te -> - `Concat (label ^ " of ", Out_type (Out_type.tree_of_typexp Type_scheme te)) + `Concat + (label ^ " of ", Out_type (Type_utils.Printtyp.tree_of_typ_scheme te)) end (* List methods of an object. diff --git a/src/analysis/type_utils.ml b/src/analysis/type_utils.ml index 39e8f29b2..507be626b 100644 --- a/src/analysis/type_utils.ml +++ b/src/analysis/type_utils.ml @@ -134,6 +134,10 @@ module Printtyp = struct (select_by_verbosity ~default:type_scheme ~verbose:(verbose_type_scheme env)) ppf ty + let tree_of_typ_scheme te = + Out_type.prepare_for_printing [ te ]; + Out_type.tree_of_typexp Type_scheme te + let type_declaration env id ppf = (select_by_verbosity ~default:type_declaration ~verbose:(verbose_type_declaration env)) diff --git a/src/analysis/type_utils.mli b/src/analysis/type_utils.mli index b0630438f..293bb1621 100644 --- a/src/analysis/type_utils.mli +++ b/src/analysis/type_utils.mli @@ -40,6 +40,8 @@ module Printtyp : sig val type_scheme : Env.t -> Format.formatter -> Types.type_expr -> unit + val tree_of_typ_scheme : Types.type_expr -> Outcometree.out_type + val modtype : Env.t -> Format.formatter -> Types.module_type -> unit val wrap_printing_env : diff --git a/tests/test-dirs/completion/issue-lsp-503.t b/tests/test-dirs/completion/issue-lsp-503.t index a681f7ac4..64fcddbf7 100644 --- a/tests/test-dirs/completion/issue-lsp-503.t +++ b/tests/test-dirs/completion/issue-lsp-503.t @@ -14,14 +14,14 @@ We complete the name of the object { "name": "map", "kind": "Value", - "desc": "('a1 -> 'b1) -> 'a1 list -> 'b1 list", + "desc": "('a -> 'b) -> 'a list -> 'b list", "info": "", "deprecated": false }, { "name": "mapi", "kind": "Value", - "desc": "(int -> 'a0 -> 'b0) -> 'a0 list -> 'b0 list", + "desc": "(int -> 'a -> 'b) -> 'a list -> 'b list", "info": "", "deprecated": false }, From b30e218c09b66b73505f604920d418cd64bd6551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulysse=20G=C3=A9rard?= Date: Fri, 10 Jan 2025 17:06:19 +0100 Subject: [PATCH 3/3] CI upgrade --- .github/workflows/ocaml-lsp-compat.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ocaml-lsp-compat.yml b/.github/workflows/ocaml-lsp-compat.yml index ba836a9b4..865f79543 100644 --- a/.github/workflows/ocaml-lsp-compat.yml +++ b/.github/workflows/ocaml-lsp-compat.yml @@ -34,7 +34,7 @@ jobs: os: - ubuntu-latest ocaml-compiler: - - ocaml-base-compiler.5.3.0~alpha1 + - ocaml-base-compiler.5.3.0 # The type of runner that the job will run on runs-on: ${{ matrix.os }} @@ -52,6 +52,6 @@ jobs: - name: Check that Merlin and OCaml-LSP are co-installable run: | opam --cli=2.1 pin --with-version=dev --no-action https://github.com/voodoos/ocaml-lsp.git#merlin-503-compat - opam --cli=2.1 pin --with-version=5.3-503 --no-action . + opam --cli=2.1 pin --with-version=5.4-503 --no-action . opam install ocaml-lsp-server --ignore-constraints-on=ocamlformat