Skip to content

test: silence unused lexical argument byte-compile warnings - #220

Open
dannywillems wants to merge 2 commits into
emacs-evil:masterfrom
dannywillems-fork:fix/byte-compile-warnings
Open

dannywillems wants to merge 2 commits into
emacs-evil:masterfrom
dannywillems-fork:fix/byte-compile-warnings

Conversation

@dannywillems

Copy link
Copy Markdown

Summary

Byte-compiling test/evil-surround-test.el produces four
Unused lexical argument 'type' warnings, one for each buffer-local
text object defined in the "create buffer local text object and surround
binding" test.

evil-define-text-object expands its body inside a let that binds its
own type variable (see the FIXME: These let-bindings shadow variables in args comment in evil-macros.el). That binding shadows the type
argument declared in the text-object signature, so the argument is never
read and the byte-compiler flags it.

This change prefixes the argument with an underscore (_type) to mark it
intentionally unused. The bodies keep referring to type, which resolves
to the macro-introduced binding, so behaviour is unchanged.

CI

This repository had no CI. I added a GitHub Actions workflow that
byte-compiles evil-surround.el with warnings treated as errors and
loads the package, across Emacs 27.2, 30.1 and snapshot, plus a
dependabot config for the actions. The workflow is green on my fork.

I scoped warnings-as-errors to the library only: the test file still
emits four "function ... is not known to be defined" warnings for text
objects created at run time inside the test body, which are inherent to
the test structure and not addressed here.

Verification

  • _type removes the four unused-argument warnings; no new warnings appear.
  • check-parens passes on the test file.
  • evil-surround.el byte-compiles cleanly with warnings-as-errors.

The four buffer-local text objects defined with evil-define-text-object
declare a type argument, but evil-define-text-object expands its body
inside a let that binds its own type variable, shadowing the argument.
The argument is therefore never read and the byte-compiler reports it as
an unused lexical argument.

Prefix the argument with an underscore to mark it intentionally unused.
The body keeps referring to type, which resolves to the macro-introduced
binding, so behaviour is unchanged.
Add a CI workflow that byte-compiles evil-surround.el with warnings
treated as errors and loads the package, across Emacs 27.2, 30.1 and
snapshot. Evil is installed from NonGNU ELPA / MELPA as a dependency.

Add a dependabot configuration to keep the GitHub Actions up to date on
a weekly schedule.
@dannywillems

Copy link
Copy Markdown
Author

This is an automated effort to help maintaining packages in the Emacs community. See https://x.com/dwillems42/status/2060720730338185699

@dannywillems

Copy link
Copy Markdown
Author

@tomdl89

tomdl89 commented Jun 1, 2026

Copy link
Copy Markdown
Member

Any reason we can't use Eask like evil does?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants