Subject: bug#69108: closed (Re: bug#69108: false-positive warning "variable ‘_’ not left unused" in if-let* and if-let)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 25 Feb 2024 08:00:03 +0000

Your bug report

#69108: false-positive warning "variable ‘_’ not left unused" in if-let* and if-let

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
69108: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69108
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#69108: false-positive warning "variable ‘_’ not left unused" in if-let* and if-let
From: Eli Zaretskii <[email-masked]>
To: Michael Heerdegen <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Sun, 25 Feb 2024 09:42:07 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Michael Heerdegen <[email-masked]>
> Cc: [email-masked],  [email-masked]
> Date: Sun, 25 Feb 2024 02:54:04 +0100
> 
> Eli Zaretskii <[email-masked]> writes:
> 
> > > [...] repeating a test.  Is this what you prefer?
> >
> > Yes, I think so.  And you could perhaps avoid repetition of
> > (cdr binding) by saving the result of (null (cdr binding)) in
> > a local variable.
> 
> I went with a separate `cond' branch added instead, I think this is even
> simpler.  Ok?

Yes, thanks.

> > > {My unsuccessful doc tweaks}
> >
> > [...] I'd prefer to separate it.
> 
> Done.  Feel free to tune it to your likes.  Or send me an "ok", then
> I'll just commit this version.

I installed them both, thanks.

Closing the bug.

Subject: false-positive warning "variable ‘_’not left unused" in if-let* and if-let
From: Konstantin Kharlamov <[email-masked]>
To: [email-masked]
Date: Wed, 14 Feb 2024 00:21:01 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

I've been writing an answer for a question on emacs.stackexchange¹ and to avoid
nested `if` and `let` clauses I used a `if-let*`, and result of one of the checks I
assigned to a `_` variable, because the variable would be left unused, it's only the
check being non-nil that mattered.

But when byte-compiled that triggered a:

    test.el:6:9: Warning: variable ‘_’ not left unused

…which is untrue, because it is unused.

The problem is present in both `if-let` and `if-let*`

# Steps to reproduce

1. Create test.el with the following code:

    ;;; -*- lexical-binding: t -*-
    (if-let*
        ((_ nil))
        (print "then clause")
      (print "else clause"))

2. M-x byte-compile test.el

## Expected

It byte-compiles with no warnings

## Actual

It compiles with a warning:

    test.el:3:7: Warning: variable ‘_’ not left unused

# Additional information

Emacs version: commit d4d5830f8a0 built two weeks ago from master.

1: https://emacs.stackexchange.com/questions/80351/delete-prettify-symbol