GNU bug report logs - #67523
check-declare doesn't account for shorthands

Previous Next

Package: emacs;

Reported by: Joseph Turner <joseph <at> ushin.org>

Date: Wed, 29 Nov 2023 09:13:02 UTC

Severity: wishlist

Full log


View this message in rfc822 format

From: Joseph Turner <joseph <at> ushin.org>
To: 67523 <at> debbugs.gnu.org
Cc: Adam Porter <adam <at> alphapapa.net>, Jonas Bernoulli <jonas <at> bernoul.li>, João Távora <joaotavora <at> gmail.com>
Subject: bug#67523: check-declare doesn't account for shorthands
Date: Wed, 29 Nov 2023 00:03:50 -0800
On Emacs 29.1, when running `check-declare-file' on a file with
`declare-function' forms, I get

Warning (check-declare): said ‘some-nice-string-utils-foobar’ was defined in
some-nice-string-utils.el: function not found

The problem is that `check-declare-verify' attempts to search for the
full symbol name using this regular expression:

(setq re (format (if cflag
                     "^[ \t]*\\(DEFUN\\)[ \t]*([ \t]*\"%s\""
                   "^[ \t]*(\\(fset[ \t]+'\\|\
cl-def\\(?:generic\\|method\\|un\\)\\|\
def\\(?:un\\|subst\\|foo\\|method\\|class\\|\
ine-\\(?:derived\\|generic\\|\\(?:global\\(?:ized\\)?-\\)?minor\\)-mode\\|\
\\(?:ine-obsolete-function-\\)?alias[ \t]+'\\|\
ine-overloadable-function\\)\\)\
[ \t]*%s\\([ \t;]+\\|$\\)")
                 (regexp-opt (mapcar 'cadr fnlist) t)))
(while (re-search-forward re nil t)
  ...
  )

where (mapcar 'cadr fnlist) is the full symbol name.

Since the full symbol name never appears in the file in which it was
defined, re-search-forward never finds it, and so "function not found".

A potential solution could be to convert the longhand symbol into its
shorthand form and pass that into re-search-forward.  This is tricky
since there may be multiple different shorthands which could yield the
same longhand form.  It might be more feasible to run re-search-forward
on a known common suffix portion of the symbol name, then with point on
the suspected definition, run `intern-soft' to get the full symbol name.

A workaround is to not use shorthands in function definitions.

Thoughts?

Joseph




This bug report was last modified 1 year and 175 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.