unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14883: warning about unused returned value from some ert shoulds
@ 2013-07-16 20:17 Glenn Morris
  2013-07-22 15:34 ` Stefan Monnier
  2013-09-05  3:06 ` Stefan Monnier
  0 siblings, 2 replies; 3+ messages in thread
From: Glenn Morris @ 2013-07-16 20:17 UTC (permalink / raw)
  To: 14883

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.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#14883: warning about unused returned value from some ert shoulds
  2013-07-16 20:17 bug#14883: warning about unused returned value from some ert shoulds Glenn Morris
@ 2013-07-22 15:34 ` Stefan Monnier
  2013-09-05  3:06 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-07-22 15:34 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 14883

> 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#14883: warning about unused returned value from some ert shoulds
  2013-07-16 20:17 bug#14883: warning about unused returned value from some ert shoulds Glenn Morris
  2013-07-22 15:34 ` Stefan Monnier
@ 2013-09-05  3:06 ` Stefan Monnier
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-09-05  3:06 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 14883-done

> 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





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-05  3:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-16 20:17 bug#14883: warning about unused returned value from some ert shoulds Glenn Morris
2013-07-22 15:34 ` Stefan Monnier
2013-09-05  3:06 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).