GNU bug report logs - #75997
(ice-9 match): warning: unused variable `failure'

Previous Next

Package: guile;

Reported by: Tomas Volf <~@wolfsden.cz>

Date: Sat, 1 Feb 2025 20:09:01 UTC

Severity: normal

To reply to this bug, email your comments to 75997 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#75997; Package guile. (Sat, 01 Feb 2025 20:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tomas Volf <~@wolfsden.cz>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 01 Feb 2025 20:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: bug-guile <at> gnu.org
Subject: (ice-9 match): warning: unused variable `failure'
Date: Sat, 01 Feb 2025 21:08:32 +0100
[Message part 1 (text/plain, inline)]
Hi,

--8<---------------cut here---------------start------------->8---
(use-modules (ice-9 match))

(match-lambda (_ #f))
--8<---------------cut here---------------end--------------->8---

This source code leads to a warning when compiled:

--8<---------------cut here---------------start------------->8---
$ guix shell guile-next -- guild compile -W3 -o /tmp/xx.go /tmp/xx.scm
/tmp/xx.scm:3:0: warning: unused variable `failure'
wrote `/tmp/xx.go'
--8<---------------cut here---------------end--------------->8---

Looking at the expansion

--8<---------------cut here---------------start------------->8---
(lambda (expr)
  (let* ((v expr)
         (failure
           (lambda ()
             ((@@ (ice-9 match) throw)
              'match-error
              "match"
              "no matching pattern"
              v)
             #f)))
    #f))
--8<---------------cut here---------------end--------------->8---

the `failure' is indeed unused.  I took a look at the source code but it
is bit beyond my current abilities, so I am not sure how to fix it.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-guile <at> gnu.org:
bug#75997; Package guile. (Wed, 26 Feb 2025 15:11:01 GMT) Full text and rfc822 format available.

Message #8 received at 75997 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tomas Volf <~@wolfsden.cz>
Cc: 75997 <at> debbugs.gnu.org
Subject: Re: bug#75997: (ice-9 match): warning: unused variable `failure'
Date: Wed, 26 Feb 2025 16:09:33 +0100
Tomas Volf <~@wolfsden.cz> skribis:

> (lambda (expr)
>   (let* ((v expr)
>          (failure
>            (lambda ()
>              ((@@ (ice-9 match) throw)
>               'match-error
>               "match"
>               "no matching pattern"
>               v)
>              #f)))
>     #f))

Hi!  Currently the unused-variable warning pass is unable to determine
that ‘failure’ was introduced by expanding a macro and thus that no
warning should be emitted.

It’s always been this way and I don’t know of a clear way to fix it.

Ludo’.




Information forwarded to bug-guile <at> gnu.org:
bug#75997; Package guile. (Fri, 28 Feb 2025 01:34:03 GMT) Full text and rfc822 format available.

Message #11 received at 75997 <at> debbugs.gnu.org (full text, mbox):

From: Tomas Volf <~@wolfsden.cz>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 75997 <at> debbugs.gnu.org
Subject: Re: bug#75997: (ice-9 match): warning: unused variable `failure'
Date: Fri, 28 Feb 2025 02:33:32 +0100
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Tomas Volf <~@wolfsden.cz> skribis:
>
>> (lambda (expr)
>>   (let* ((v expr)
>>          (failure
>>            (lambda ()
>>              ((@@ (ice-9 match) throw)
>>               'match-error
>>               "match"
>>               "no matching pattern"
>>               v)
>>              #f)))
>>     #f))
>
> Hi!  Currently the unused-variable warning pass is unable to determine
> that ‘failure’ was introduced by expanding a macro and thus that no
> warning should be emitted.
>
> It’s always been this way and I don’t know of a clear way to fix it.

I cannot really help regarding the general case.  However in this
specific it would likely suffice to tweak the expansion to

--8<---------------cut here---------------start------------->8---
(lambda (expr)
  (let* ((v expr)
         (failure
           (lambda ()
             ((@@ (ice-9 match) throw)
              'match-error
              "match"
              "no matching pattern"
              v)
             #f)))
    failure
    #f))
--8<---------------cut here---------------end--------------->8---

Should have zero performance impact due to optimizations (I would hope),
but feels somewhat ugly.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 42 days ago.

Previous Next


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