#603 no warning on bad :report function in define-condition

lisp error
closed-fixed
clisp (525)
5
2011-08-03
2011-08-02
No

(define-condition simple-foo (simple-error)
()
(:report (lambda (condition)
(let ((fstring (simple-condition-format-control condition)))
(if fstring
(apply #'format stream fstring
(simple-condition-format-arguments condition))
(clos:call-next-method))))))

the :report lambda is bad: it takes one argument instead of two.
however, no warning is issued because define-condition macroexpands to

(PROGN (DEFCLASS SIMPLE-FOO (SIMPLE-ERROR) NIL)
(DEFMETHOD PRINT-OBJECT ((CONDITION SIMPLE-FOO) STREAM)
(IF (OR *PRINT-ESCAPE* *PRINT-READABLY*) (CALL-NEXT-METHOD)
(PROGN
(FUNCALL
#'(LAMBDA (CONDITION)
(LET ((FSTRING (SIMPLE-CONDITION-FORMAT-CONTROL CONDITION)))
(IF FSTRING
(APPLY #'FORMAT STREAM FSTRING
(SIMPLE-CONDITION-FORMAT-ARGUMENTS CONDITION))
(CALL-NEXT-METHOD))))
CONDITION STREAM)
CONDITION)))
'SIMPLE-FOO)

and the lambda lives inside a print-object method where STEAM is already bound.
(if STREAM is replaced by ZZZ inside the body of lambda, there _is_ a warning!)
ergo: funcall should issue a warning here.

Discussion

  • Sam Steingold

    Sam Steingold - 2011-08-02
    • assigned_to: haible --> sds
     
  • Sam Steingold

    Sam Steingold - 2011-08-02

    also should warn:
    (mapcar (lambda () 1) '(1 2 3))

     
  • Sam Steingold

    Sam Steingold - 2011-08-03
    • status: open --> closed-fixed
     
  • Sam Steingold

    Sam Steingold - 2011-08-03

    thank you for your bug report.
    the bug has been fixed in the source tree (mercurial/hg).
    you can either wait for the next release (recommended)
    or check out the current mercurial tree (see http://clisp.org\)
    and build CLISP from the sources (be advised that between
    releases the source tree is very unstable and may not even build
    on your platform).

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks