1.0.21.6: muffle compiler notes from EVAL and function generator construction
authorNikodemus Siivola <nikodemus@random-state.net>
Mon, 6 Oct 2008 09:14:27 +0000 (09:14 +0000)
committerNikodemus Siivola <nikodemus@random-state.net>
Mon, 6 Oct 2008 09:14:27 +0000 (09:14 +0000)
 * 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.

NEWS
contrib/sb-cltl2/compiler-let.lisp
contrib/sb-cltl2/tests.lisp
src/code/eval.lisp
src/pcl/fngen.lisp
tests/clos.impure.lisp
tests/eval.impure.lisp
version.lisp-expr

diff --git a/NEWS b/NEWS
index 4c45d3f..d0619b8 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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)
index 6b82f8d..e7458dd 100644 (file)
@@ -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))))))))
index ac775c9..137b055 100644 (file)
     (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)
 
index 9529f29..f639dd7 100644 (file)
   ;; 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)))
 
index 8488fe5..548974a 100644 (file)
 
 (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))))
index 3dc1d93..d548cff 100644 (file)
 (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)))
 \f
 ;;;; success
index c5de28b..2e6d502 100644 (file)
 (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
index 3985b86..34068eb 100644 (file)
@@ -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"