Don't warn when #'(setf fun) is used in the presence of a setf-macro.
[sbcl.git] / src / compiler / compiler-error.lisp
index a9b6ef5..41a1d3b 100644 (file)
@@ -82,7 +82,7 @@
 ;;; CSR, 2003-05-13
 (define-condition compiler-error (encapsulated-condition) ()
   (:report (lambda (condition stream)
-            (print-object (encapsulated-condition condition) stream))))
+             (print-object (encapsulated-condition condition) stream))))
 
 ;;; Signal the appropriate condition. COMPILER-ERROR calls the bailout
 ;;; function so that it never returns (but compilation continues).
   (let ((condition (coerce-to-condition datum arguments
                                         'simple-program-error 'compiler-error)))
     (restart-case
-        (progn
-          (cerror "Replace form with call to ERROR."
-                  'compiler-error
-                  :condition condition)
-          (funcall *compiler-error-bailout* condition)
-          (bug "Control returned from *COMPILER-ERROR-BAILOUT*."))
+        (cerror "Replace form with call to ERROR."
+                'compiler-error
+                :condition condition)
       (signal-error ()
-        (error condition)))))
+        (error condition)))
+    (funcall *compiler-error-bailout* condition)
+    (bug "Control returned from *COMPILER-ERROR-BAILOUT*.")))
 
-(declaim (ftype (function (string &rest t) (values))
-                compiler-warn compiler-style-warn))
-(defun compiler-warn (format-string &rest format-args)
-  (apply #'warn format-string format-args)
+(defmacro with-compiler-error-resignalling (&body body)
+  `(handler-bind
+       ((compiler-error
+          (lambda (c)
+            (if (boundp '*compiler-error-bailout*)
+                ;; if we're in the compiler, delegate either to a higher
+                ;; authority or, if that's us, back down to the
+                ;; outermost compiler handler...
+                (signal c)
+                ;; ... if we're not in the compiler, better signal the
+                ;; error straight away.
+                (invoke-restart 'signal-error)))))
+     ,@body))
+
+(defun compiler-warn (datum &rest arguments)
+  (apply #'warn datum arguments)
   (values))
 
-(defun compiler-style-warn (format-string &rest format-args)
-  (apply #'style-warn format-string format-args)
+(defun compiler-style-warn (datum &rest arguments)
+  (apply #'style-warn datum arguments)
   (values))
 
+(defun source-to-string (source)
+  (write-to-string source
+                   :escape t :readably nil :pretty t
+                   :circle t :array nil))
+
 (defun make-compiler-error-form (condition source)
   `(error 'compiled-program-error
           :message ,(princ-to-string condition)
-          :source ,(princ-to-string source)))
+          :source ,(source-to-string source)))
 
 ;;; Fatal compiler errors. We export FATAL-COMPILER-ERROR as an
 ;;; interface for errors that kill the compiler dead
 ;;; deeply confused, so we violate what'd otherwise be good compiler
 ;;; practice by not trying to recover from this error and bailing out
 ;;; instead.)
-(define-condition input-error-in-compile-file (fatal-compiler-error)
+(define-condition input-error-in-compile-file (reader-error encapsulated-condition)
   (;; the position where the bad READ began, or NIL if unavailable,
    ;; redundant, or irrelevant
    (position :reader input-error-in-compile-file-position
-            :initarg :position
-            :initform nil))
+             :initarg :position
+             :initform nil))
   (:report
    (lambda (condition stream)
      (format stream
-            "~@<~S failure in ~S~@[ at character ~W~]: ~2I~_~A~:>"
-            'read
-            'compile-file
-            (input-error-in-compile-file-position condition)
-            (encapsulated-condition condition)))))
+             "~@<~S error during ~S:~
+                ~@:_ ~2I~_~A~
+                  ~@[~@:_~@:_(in form starting at ~:{~(~A~): ~S~:^, ~:_~})~]~
+              ~:>"
+             'read
+             'compile-file
+             (encapsulated-condition condition)
+             (when (input-error-in-compile-file-position condition)
+               (sb!kernel::stream-error-position-info
+                (stream-error-stream condition)
+                (input-error-in-compile-file-position condition)))))))