universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.38k stars 618 forks source link

Haskell: reference to too generic part of the type signature emitted when tagging Haskell source with multi-line type signature #4013

Closed robinp closed 2 weeks ago

robinp commented 3 weeks ago

Hello! This happens when formatting long Haskell type signatures with brittany, which will then break up the type signature to multiple lines (normally it is a single line). In this case ctags seems to emit a reference to the second line of the type signature, which is too generic and matches other locations too.

The name of the parser: (not sure what the parser refers to, but Haskell?)

The command line you used to run ctags:

$ ctags --options=NONE /tmp/ctest/foo.hs

The content of input file:

module Foo () where

thing
    :: App m
    => Int
    -> m Int
thing x = pure x

The tags output you are not satisfied with:

...
!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //
!_TAG_PROGRAM_NAME      Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL       https://ctags.io/       /official site/
!_TAG_PROGRAM_VERSION   6.1.0   /v6.1.0/
Foo     /tmp/ctest/foo.hs       /^module Foo () where$/;"       m
thing   /tmp/ctest/foo.hs       /^    :: App m$/;"      f
thing   /tmp/ctest/foo.hs       /^thing x = pure x$/;"  f

The tags output you expect:

Not sure, but the first regex that matches thing to the second line of the multi-line type signature is not ok. Since that regex happens multiple times in the file (for different functions), doing a tag-based navigation in vim would jump to a likely wrong location.

For my usecase it could work if the type signature-y tagline would be omitted. More generally, a more specific match should be generated somehow (multi-line match, that includes the first line of the type sig too?).

The version of ctags:

$ ctags --version
Universal Ctags 6.1.0(v6.1.0), Copyright (C) 2015-2023 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Dec 28 2023, 18:49:35
  URL: https://ctags.io/
  Output version: 0.0
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +xpath, +json, +interactive, +sandbox, +yaml, +packcc, +optscript, +pcre2

How do you get ctags binary:

Arch pacman.