GNU bug report logs - #14883
warning about unused returned value from some ert shoulds

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 16 Jul 2013 20:18:01 UTC

Severity: minor

Found in version 24.3

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14883 in the body.
You can then email your comments to 14883 AT debbugs.gnu.org in the normal way.

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-gnu-emacs <at> gnu.org:
bug#14883; Package emacs. (Tue, 16 Jul 2013 20:18:01 GMT) Full text and rfc822 format available.

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

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: warning about unused returned value from some ert shoulds
Date: Tue, 16 Jul 2013 16:17:05 -0400
Package: emacs
Version: 24.3
Severity: minor

Compiling a file with contents:

    ;; -*- lexical-binding: t; -*-
    (require 'ert)
    (require 'cl-lib)
    (defvar foo-test 1)
    (should foo-test)
    (cl-assert foo-test)

results in a warning (for some reason, only when lexical-binding is t):

   foo.el:5:1:Warning: value returned from (car value-94600) is unused

The warning is from the `should'. Obviously it is a bogus warning
because the whole point of the should is to test the return value.
The similar cl-assert does not trigger a warning, because internally
cl-assert is written differently.

This is the same issue as http://debbugs.gnu.org/10969, for what is now
cl-pop.

byte-optimize-form-code-walker has special handling for the standard
`pop' macro so as not to warn about unused return values from (pop foo).
It would be nice if there was a general way to get the same result for
arbitrary macros (sort of the opposite of side-effect-free?), but I
don't see how.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#14883; Package emacs. (Mon, 22 Jul 2013 15:35:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14883 <at> debbugs.gnu.org
Subject: Re: bug#14883: warning about unused returned value from some ert
 shoulds
Date: Mon, 22 Jul 2013 11:34:49 -0400
> This is the same issue as http://debbugs.gnu.org/10969, for what is now
> cl-pop.

There's no `cl-pop'.  Instead `pop' is now always like CL's `pop'.

> byte-optimize-form-code-walker has special handling for the standard
> `pop' macro so as not to warn about unused return values from (pop foo).
> It would be nice if there was a general way to get the same result for
> arbitrary macros (sort of the opposite of side-effect-free?), but I
> don't see how.

I think the way to do it is to introduce a new function (call it
`ignorable') which works like `identity' and then make pop use it around
the code that returns the value.

Then byte-optimize-form-code-walker can be modified to recognize this
function and just throw away the whole call when `for-effect' is nil.
We can then get rid of this ad-hoc handling of `pop'.


        Stefan




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Thu, 05 Sep 2013 03:07:02 GMT) Full text and rfc822 format available.

Notification sent to Glenn Morris <rgm <at> gnu.org>:
bug acknowledged by developer. (Thu, 05 Sep 2013 03:07:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 14883-done <at> debbugs.gnu.org
Subject: Re: bug#14883: warning about unused returned value from some ert
 shoulds
Date: Wed, 04 Sep 2013 23:06:38 -0400
> Compiling a file with contents:
>     ;; -*- lexical-binding: t; -*-
>     (require 'ert)
>     (require 'cl-lib)
>     (defvar foo-test 1)
>     (should foo-test)
>     (cl-assert foo-test)
> results in a warning (for some reason, only when lexical-binding is t):
>    foo.el:5:1:Warning: value returned from (car value-94600) is unused

This `car' came from the closure conversion.  I believe it is now fixed
in the trunk.  Thank you.


        Stefan




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 03 Oct 2013 11:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 221 days ago.

Previous Next


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