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

Occurrences of None returns invalid matches from default parameter #1410

Open
mattiase opened this issue Dec 7, 2021 · 3 comments
Open

Occurrences of None returns invalid matches from default parameter #1410

mattiase opened this issue Dec 7, 2021 · 3 comments
Labels

Comments

@mattiase
Copy link
Contributor

mattiase commented Dec 7, 2021

Consider the file:

(* test case *)
let f ?(x=1) () = 2 ;;
None

Occurrences on the location of None returns a match at that same position as well as one at an invalid position (line 0, column -1). It appears to be linked to the default argument somehow.

Of course we can filter out matches at invalid positions, either in merlin proper or in whatever code making use of the output (like the Emacs lisp code), but it would be better to to generate them in the first place. Maybe there are more such cases that become apparent if the source of them is found.

voodoos added a commit to voodoos/merlin that referenced this issue Dec 17, 2021
@voodoos
Copy link
Collaborator

voodoos commented Dec 17, 2021

Thank you for the report! I added a test illustrating the issue.
A major rework of that feature is planned in a not-so-distant future...

mattiase added a commit to mattiase/merlin that referenced this issue Dec 17, 2021
For some reason, the occurrences command output sometimes contains
bogus locations (line 0, col -1). It really shouldn't, but filter
them out until that has been fixed (ocaml#1410).
@mattiase
Copy link
Contributor Author

Thanks – I added a simple filter to the Emacs Xref PR (#1385) for the time being.

I presume you were thinking about making Occurrence project-wide? That would be really nice to have.

@voodoos
Copy link
Collaborator

voodoos commented Dec 17, 2021

Yes, that is part of the plan :-)

mattiase added a commit to mattiase/merlin that referenced this issue Dec 17, 2021
For some reason, the occurrences command output sometimes contains
bogus locations (line 0, col -1). It really shouldn't, but filter
them out until that has been fixed (ocaml#1410).
mattiase added a commit to mattiase/merlin that referenced this issue Nov 24, 2022
For some reason, the occurrences command output sometimes contains
bogus locations (line 0, col -1). It really shouldn't, but filter
them out until that has been fixed (ocaml#1410).
mattiase added a commit to mattiase/merlin that referenced this issue Dec 22, 2022
For some reason, the occurrences command output sometimes contains
bogus locations (line 0, col -1). It really shouldn't, but filter
them out until that has been fixed (ocaml#1410).
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants