Subject: bug#47408: Etags support for Mercury [v0.5]

From: fabrice nicol <[email-masked]>
Date: Thu, 10 Jun 2021 18:52:49 +0200

Eli,

your latest fix for Mercury 'etags' support has introduced a regression 
for existentially quantified predicates.

These predicates have the following (somewhat simplified) syntax (in 
extended regexp  form, \s for white space):

:-[:blank:]+some[:blank:]*\[[:blank:]*T(,[:blank:]*[:upper:]{1})*[:blank:]*\][:blank:]+pred[:blank:]+([:lower:]+([:alnum:]|[:punct:])*)+[:blank:]*\([^()]+\)([:blank:]|[:lower:])*\.

Example:

:- some [T] pred unravel_univ(univ::in, T::out) is det.

Your fix incorrectly outputs such quantified predicates. For example on 
tagging univ.m (attached), your commit version yields:

:- some [T] pred unravel_univ(^?[T] pred unravel_univ^A141,4333

whilst my original code yields the correct tag:

:- some [T] pred unravel_univ(^?141,4333

In other words, 'pred unravel_univ' is wrongly repeated in your latest 
commit.

The issue seems to be located at the patch line below:

+ char *name = skip_non_spaces (s + len0);

Pending a more accurate 'fix for the fix', it would probably be wiser to 
revert to original code, as it - at least - gives a correct output for 
'etags' invocation.

Existentially quantified predicates are not uncommon in Mercury.

Fabrice

>> Date: Tue, 08 Jun 2021 14:47:13 +0200
>> Cc: [email-masked],
>> 	[email-masked]
>>
>>>> I just looked at the code.  Unless I am grossly mistaken, nothing is
>>>> needed to get ctags output.  You just call the program as ctags and
>>>> that's it.  So there is no reason to prevent ctags help from mentioning
>>>> Mercurial.
>>> Then how come, when I run the etags test suite (test/manual/etags/), I
>>> get no change in the produced CTAGS file wrt CTAGS.good?  That .good
>>> file is from before we added the Mercury source to the suite.  What am
>>> I missing?
>> Sorry, don't know :(  Looked again, but then I'd need to debug it to know...
> I found the reason: make_tag was called incorrectly from mercury_pr.
>
> This should be fixed now.