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

merlin is missing unused (type|open|value|constructor|field) warnings #1593

Open
copy opened this issue Apr 20, 2023 · 1 comment
Open

merlin is missing unused (type|open|value|constructor|field) warnings #1593

copy opened this issue Apr 20, 2023 · 1 comment

Comments

@copy
Copy link
Contributor

copy commented Apr 20, 2023

e.g.:

open Printf

module type X = sig end

let x =
  let y = 42 in
  ()

let _f x = ()

type x = {
  foo: int }
type y =
  | Foo

let () = for i = 0 to 0 do () done

with an empty test.mli and the following dune:

(executable (name test))

There are a bunch of different unused warnings (I didn't manage to get an unused module warning out of the compiler):

% dune clean && dune build test.exe
File "test.ml", line 1, characters 0-11:
1 | open Printf
    ^^^^^^^^^^^
Error (warning 33 [unused-open]): unused open Stdlib.Printf.
File "test.ml", line 5, characters 4-5:
5 | let x =
        ^
Error (warning 32 [unused-value-declaration]): unused value x.
File "test.ml", line 6, characters 6-7:
6 |   let y = 42 in
          ^
Error (warning 26 [unused-var]): unused variable y.
File "test.ml", line 9, characters 7-8:
9 | let _f x = ()
           ^
Error (warning 27 [unused-var-strict]): unused variable x.
File "test.ml", lines 11-12, characters 0-12:
11 | type x = {
12 |   foo: int }
Error (warning 34 [unused-type-declaration]): unused type x.
File "test.ml", line 12, characters 2-10:
12 |   foo: int }
       ^^^^^^^^
Error (warning 69 [unused-field]): unused record field foo.
File "test.ml", lines 13-14, characters 0-7:
13 | type y =
14 |   | Foo
Error (warning 34 [unused-type-declaration]): unused type y.
File "test.ml", line 14, characters 2-7:
14 |   | Foo
       ^^^^^
Error (warning 37 [unused-constructor]): unused constructor Foo.
File "test.ml", line 16, characters 9-34:
16 | let () = for i = 0 to 0 do () done
              ^^^^^^^^^^^^^^^^^^^^^^^^^
Error (warning 35 [unused-for-index]): unused for-loop index i.

But merlin only reports warning 26:

% ocamlmerlin single errors < test.ml |jq
{
  "class": "return",
  "value": [
    {
      "start": {
        "line": 6,
        "col": 6
      },
      "end": {
        "line": 6,
        "col": 7
      },
      "type": "warning",
      "sub": [],
      "valid": true,
      "message": "Warning 26: unused variable y."
    }
  ],
  "notifications": [],
  "timing": {
    "clock": 2,
    "cpu": 2,
    "query": 0,
    "pp": 0,
    "reader": 0,
    "ppx": 0,
    "typer": 2,
    "error": 0
  }
}

This is with merlin 4.8-500.

@voodoos
Copy link
Collaborator

voodoos commented Apr 20, 2023

Yes, these warnings have always been disabled in Merlin: 1f1fee1

(* Some warnings are not properly implemented in merlin, just disable *)
let disabled x = (x >= 32 && x <= 39)

I always assumed that the reason was to not bother the user while writing code since most values start their life unused.
But the comment in the code actually says Some warnings are not properly implemented in merlin, just disable which I find a bit surprising.

@let-def could you give us some insight about this ?

Linked-issue: #485

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