Skip to content

Commit

Permalink
1.0.21.6: muffle compiler notes from EVAL and function generator cons…
Browse files Browse the repository at this point in the history
…truction

 * Just add (DECLARE (MUFFLE-CONDITIONS COMPILER-NOTE)) to the lambdas
   we cons up: in case of EVAL the notes are distractive and seem
   pointless, and in case of generators the user is definitely not
   interested.

 * Adjust SB-CLTL2 tests slightly to account for possible pre-existing
   MUFFLE-CONDITIONS declarations, and fix usage of SPECIAL-BINDINGS.
  • Loading branch information
nikodemus committed Oct 6, 2008
1 parent 666a3a7 commit b3fc19f
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 6 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
;;;; -*- coding: utf-8; -*-
changes in sbcl-1.0.22 relative to 1.0.21:
* enhancement: inoccous calls to EVAL or generic functions dispatching
on subclasses of eg. STREAM no longer cause compiler notes to appear.
* bug fix: ADJUST-ARRAY on multidimensional arrays used bogusly give
them a fill pointer unless :DISPLACED-TO or :INITIAL-CONTENTS were
provided. (reported by Cedric St-Jean)
Expand Down
2 changes: 1 addition & 1 deletion contrib/sb-cltl2/compiler-let.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
finally (return
(let ((new-env (sb-eval::make-env
:parent env
:vars (sb-eval::special-bindings vars))))
:vars (sb-eval::special-bindings vars env))))
(progv vars values
(sb-eval::eval-progn body new-env))))))))
6 changes: 4 additions & 2 deletions contrib/sb-cltl2/tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,14 @@
(dinfo sb-ext:muffle-conditions))
warning)
(deftest declaration-information.muffle-conditions.2
(locally (declare (sb-ext:muffle-conditions warning))
(let ((junk (dinfo sb-ext:muffle-conditions)))
(declare (sb-ext:muffle-conditions warning))
(locally (declare (sb-ext:unmuffle-conditions style-warning))
(let ((dinfo (dinfo sb-ext:muffle-conditions)))
(not
(not
(and (subtypep dinfo '(and warning (not style-warning)))
(and (subtypep dinfo `(or (and warning (not style-warning))
(and ,junk (not style-warning))))
(subtypep '(and warning (not style-warning)) dinfo)))))))
t)

Expand Down
7 changes: 6 additions & 1 deletion src/code/eval.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@
;; to be careful about not muffling warnings arising from inner
;; evaluations/compilations, though [e.g. the ignored variable in
;; (DEFUN FOO (X) 1)]. -- CSR, 2003-05-13
;;
;; As of 1.0.21.6 we muffle compiler notes lexically here, which seems
;; always safe. --NS
(let* (;; why PROGN? So that attempts to eval free declarations
;; signal errors rather than return NIL. -- CSR, 2007-05-01
(lambda `(lambda () (progn ,expr)))
(lambda `(lambda ()
(declare (muffle-conditions compiler-note))
(progn ,expr)))
(fun (sb!c:compile-in-lexenv nil lambda lexenv)))
(funcall fun)))

Expand Down
4 changes: 3 additions & 1 deletion src/pcl/fngen.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@

(defun get-new-fun-generator (lambda test code-converter)
(multiple-value-bind (code gensyms) (compute-code lambda code-converter)
(let ((generator-lambda `(lambda ,gensyms (function ,code))))
(let ((generator-lambda `(lambda ,gensyms
(declare (muffle-conditions compiler-note))
(function ,code))))
(let ((generator (compile nil generator-lambda)))
(ensure-fgen test gensyms generator generator-lambda nil)
generator))))
Expand Down
20 changes: 20 additions & 0 deletions tests/clos.impure.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,5 +1619,25 @@
(handler-bind ((warning #'error))
(assert (= 123 (slot-value (provoke-ctor-default-initarg-problem) 'slot))))

;;;; discriminating net on streams used to generate code deletion notes on
;;;; first call
(defgeneric stream-fd (stream direction))
(defmethod stream-fd ((stream sb-sys:fd-stream) direction)
(declare (ignore direction))
(sb-sys:fd-stream-fd stream))
(defmethod stream-fd ((stream synonym-stream) direction)
(stream-fd (symbol-value (synonym-stream-symbol stream)) direction))
(defmethod stream-fd ((stream two-way-stream) direction)
(ecase direction
(:input
(stream-fd
(two-way-stream-input-stream stream) direction))
(:output
(stream-fd
(two-way-stream-output-stream stream) direction))))
(with-test (:name (:discriminating-name :code-deletion-note))
(handler-bind ((compiler-note #'error))
(stream-fd sb-sys:*stdin* :output)
(stream-fd sb-sys:*stdin* :output)))

;;;; success
11 changes: 11 additions & 0 deletions tests/eval.impure.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,15 @@
(with-test (:name :toplevel-declare)
(assert (raises-error? (eval '(declare (type pathname *scratch*))))))

(with-test (:name (eval no-compiler-notes))
(handler-bind ((sb-ext:compiler-note #'error))
(let ((sb-ext:*evaluator-mode* :compile))
(eval '(let ((x 42))
(if nil x)))
(eval '(let ((* 13))
(let ((x 42)
(y *))
(declare (optimize speed))
(+ x y)))))))

;;; success
2 changes: 1 addition & 1 deletion version.lisp-expr
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
"1.0.21.5"
"1.0.21.6"

0 comments on commit b3fc19f

Please sign in to comment.