(ice-9 match): warning: unused variable `failure'

  • Open
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Tomas Volf
Owner
unassigned
Submitted by
Tomas Volf
Severity
normal

Debbugs page

Tomas Volf wrote 1 months ago
(address . bug-guile@gnu.org)
871pwha0n3.fsf@wolfsden.cz
Hi,

Toggle snippet (5 lines)
(use-modules (ice-9 match))

(match-lambda (_ #f))

This source code leads to a warning when compiled:

Toggle snippet (5 lines)
$ 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'

Looking at the expansion

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

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.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmeef0AOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/wanrpQ//RikmfAJM1tVYnW/ei9k+esLOQ1+TXs8KjMbG
ijw1UdNp81jDvZVqbHdBiN5Hi/XmiywHjHdOgIpWd7OMhHPyBWXx1CsunDfV8V9I
ZEXxg3ruLAk4DKD4i/bobuK2P1khgeIFTxptdjgpZw3GS25fZfdgoUlzsPt4wrmQ
4YWIiKzgGQE//+D/geH9vs/MyOneGNiAF/QlDunkIKcy4owmmk7kTKhgql3JnNNC
AmFDF85fYBgOx9UuMq+vW50T6nCoPRs36sj/3kVDtnvW3dp+tiwx6iNg7uBBw8CX
GZWA/CCzbG8lE9zkZ4W47B6XdDHykcobx8qaG+I0n/7wT6WDcQexcygzW8XTB411
mDJMOwiyPFbT05L8oNb4PK+eN9F7w9qj6l0wmhJoOTb6/y3i4va2sOxX4OOjeq7i
3WGWfoCDXowfIwEe3JduX/W/9Q56pAbnu2MY6HlPPT1t7FkGr3HNmw/uLncsEveA
FBKca1jklP6JWam7PeYiSY/NBVGgXNpESkAmLw5pzu+EqW1e30K8NiYGF7ojh8/i
Uyp3IsOn/jzH/s7nkFiZSPbqYpY7wknJHnFzc+VyoqvfOIQZnOgANb3EiXbjU8mw
EuYUkLmdlnWbBze1yw/jsmHEWM8soqV/Y75s8Jr+1QaNk3wEb4Aj8KDHMEH+RCoc
memGOIk=
=CXsg
-----END PGP SIGNATURE-----

Ludovic Courtès wrote 3 weeks ago
(name . Tomas Volf)(address . ~@wolfsden.cz)(address . 75997@debbugs.gnu.org)
87wmdc3fpu.fsf@gnu.org
Tomas Volf <~@wolfsden.cz> skribis:

Toggle quote (12 lines)
> (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’.
Tomas Volf wrote 2 weeks ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 75997@debbugs.gnu.org)
87o6ymq2dv.fsf@wolfsden.cz
Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (20 lines)
> 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

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

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.
-----BEGIN PGP SIGNATURE-----

iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmfBEmwOHH5Ad29sZnNk
ZW4uY3oACgkQL7/ufbZ/waksuw//TT38tBOHLv/Vv+DvJ4QyPyATjN6QI+nPrxjx
PJJfCedBoXQ5DwOucATU6+en18t0CCajunxNKMKkQokTYOUxHvaStV6pXBSwx9pX
7T97whZEl3mnzqqZrcLMjHwcpuSfU6QBTY3u5WC0XVuzfA5WFN3a7m3t4ca0VpTb
Nbq02coTRUZ/AypLp0mipMC9gwIFgXEbHoDAg56gImuhV/9zvYG/gND+hrZKI0aq
baOj2E1zEWH4hUeePZj+J8dmTIWHJH0XuXbSKkR5RGQXEcJk/d6SuMyygCSkoIwQ
5oBKWxwLD7553bZcq4b9CU75YiTqa4/vcu+j4ItiLZULyo95msxrpHqubvxvr0WV
/+81n5mRRT/HlaT6r/13/il2EcJJgitDeO/Cd5KvudVrPs3QuK2E1dQ/v1fyOkIO
COLW7eLCI/H6eK1zKJwwHCLEPxVZuMkGvUlLt1+6BUdrHEmM4RqQrhhZUIyKrf9T
ZhadPtb6Zms4g/XE2beTQMBsIxpQBzKg6PZBKejf8mE+VxP5ykeItYRBATU97D1z
4HfmrJ2xtANkdtq9hLFyIzgmnfGxiepeTIPGMhfw4V2Zleas5gYGMrcq6ojakvyQ
vi4wr2QecugLFXVC2MXg3KXgdxaOp0BZvF9R13PrdUTrUZVVZF0aHj9jCdzSRJ30
7UZT5vI=
=9v2G
-----END PGP SIGNATURE-----

?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 75997@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 75997
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help