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

Flycheck's Emacs Lisp checker is unable to identify functions defined in nested block #2038

Open
3 of 6 tasks
GongYiLiao opened this issue Oct 11, 2023 · 0 comments
Open
3 of 6 tasks

Comments

@GongYiLiao
Copy link

GongYiLiao commented Oct 11, 2023

Thank you for taking the time to report an issue and improve Flycheck. This template is for actual bugs you observed. If you have trouble setting up Flycheck, or if you have a question, please use the relevant issue template instead.

Checklist

  • I have checked existing issues for potential duplicates before creating this one.
  • I have read the Troubleshooting guide.

Bug description

A clear and concise description of what the bug is.

Steps to reproduce

Steps to reproduce the behavior:
Use the following code:

;;; Code:

(require 'elint)

(defun kkl0-fun ()
  "Test."
  (message "testn kk0-funl"))

(kkl0-fun)

(defvar *kk0l* t)

(elint-update-env)

(when *kk0l*
  (defun kkl1-fun () (message "test kkl1-fun")))



(kkl1-fun)

(kkl1-fun)

(kkl2-fun)

(kkl2-fun)


;;; test.el ends here

The flycheck will shows the following diagnositc:

Screenshot from 2023-10-11 08-56-48

we can see the following probelm:

  1. kkl0-fun, which is defined at top-level, linter shows no error
    at all about it
  2. kkl1-fun is defined as long as the *kk0l* global variable
    is assigned as t
  3. The first linter error appears when the kkl1-fun is called first
    time
  4. At the second call-site of kkl1-fun, the linter "undefined-unction"
    error disappears
  5. kkl2-fun is totally undefined, and linter identifies the
    undefined function error at its first call-site
  6. at the second call-site of kkl2-fun, the undefined-function linter
    error disappears as well

These suggest that

  1. flycheck's emacs lisp linter is unable to identify functions defined within some control block such as when
  2. flycheck's emacs lisp linter will not report error for undefined furnction starting from teh second call site

However, if we use built-in elint.el, we got the following expected output from elint-curretn-buffer:

Screenshot from 2023-10-11 13-45-09

Expected behavior

Emacs lisp functions defined in nested block should be identified just like those functions defined at top-level, the the report of undefined functions should be consistent
your problem.

System configuration

Syntax checkers for buffer test.el in emacs-lisp-mode:

First checker to run:

  emacs-lisp
    - may enable:    yes
    - may run:       t
    - executable:    Found at /home/kiong-ge/.local/emacs/29/bin/emacs
    - next checkers: emacs-lisp-checkdoc

Checkers that may run as part of the first checker's chain:

  emacs-lisp-checkdoc
    - may enable: yes
    - executable: Found at /home/kiong-ge/.local/emacs/29/bin/emacs

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled
checkers.

--------------------

Flycheck version: 33snapshot (package: 20230813.620)
Emacs version:    29.1
System:           x86_64-pc-linux-gnu
Window system:    pgtk

Emacs configuration:

  • Plain Emacs / Custom configuration
  • Spacemacs
  • Doom Emacs
  • Other shared configuration

Additional notes

Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant