From: Nikodemus Siivola Date: Sun, 4 Jul 2004 22:30:03 +0000 (+0000) Subject: 0.8.12.21: The same finnish twit who broke the manual also left X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=c2fd998cbeea4a2049e8b77bf36c6e478ebb7d44;p=sbcl.git 0.8.12.21: The same finnish twit who broke the manual also left unaccounted several pathological cases in his COMPILER-ERROR reorganization. * Revert to a less fancy, but more robust scheme, one that never requires MAKE-LOAD-FORM for dumping COMPILED-PROGRAM-ERRORS. The informational benefits of the earlier patch are unaffected. * Tests for at least some of those pathological cases in case someone comes up with the same brilliant idea. --- diff --git a/package-data-list.lisp-expr b/package-data-list.lisp-expr index 76f327f..b4f3176 100644 --- a/package-data-list.lisp-expr +++ b/package-data-list.lisp-expr @@ -746,10 +746,7 @@ retained, possibly temporariliy, because it might be used internally." "*SETF-FDEFINITION-HOOK*" ;; error-reporting facilities - "MAKE-CONDITION-LOAD-FORM" - "COMPILED-PROGRAM-ERROR" - "ENCAPSULATED-CONDITION" - "MAKE-LOAD-FORM-ERROR" + "ENCAPSULATED-CONDITION" "COMPILED-PROGRAM-ERROR" "SIMPLE-CONTROL-ERROR" "SIMPLE-FILE-ERROR" "SIMPLE-PARSE-ERROR" "SIMPLE-PROGRAM-ERROR" "SIMPLE-STREAM-ERROR" diff --git a/src/code/condition.lisp b/src/code/condition.lisp index f462146..65e9697 100644 --- a/src/code/condition.lisp +++ b/src/code/condition.lisp @@ -557,25 +557,6 @@ (condition-actual-initargs condition) (condition-assigned-slots condition)))) -;;;; MAKE-LOAD-FORM equivalent for conditions. - -;;; We need this to be able to dump arbitrary encapsulated conditions -;;; with MAKE-LOAD-FORM for COMPILED-PROGRAM-ERRORs. Unfortunately -;;; ANSI specifies that MAKE-LOAD-FORM for conditions should signal an -;;; error, despite the fact that it also specifies that the -;;; file-compiler should use MAKE-LOAD-FORM for conditions. Bah. -;;; Badness results if this is called before PCL is in place. Unlike -;;; real make-load-form we return just a single form, so that it can -;;; easily be embedded in the surrounding condition. -(defun make-condition-load-form (condition &optional env) - (with-unique-names (instance) - (multiple-value-bind (create init) - (make-load-form-saving-slots condition :environment env) - (let ((fixed-init (subst instance condition init))) - `(let ((,instance ,create)) - ,fixed-init - ,instance))))) - ;;;; various CONDITIONs specified by ANSI (define-condition serious-condition (condition) ()) diff --git a/src/code/error.lisp b/src/code/error.lisp index daa38c7..b80994e 100644 --- a/src/code/error.lisp +++ b/src/code/error.lisp @@ -70,60 +70,15 @@ (case-failure-name condition) (case-failure-possibilities condition))))) -(define-condition compiled-program-error (encapsulated-condition program-error) - ((source :initarg :source :reader program-error-source)) +(define-condition compiled-program-error (program-error) + ((message :initarg :message :reader program-error-message) + (source :initarg :source :reader program-error-source)) (:report (lambda (condition stream) - (let ((source (program-error-source condition))) - ;; Source may be either a list or string, and - ;; string needs to be printed without escapes. - (format stream "Execution of a form compiled with errors.~%~ - Form:~% ~ - ~:[~S~;~A~]~%~ - Compile-time-error:~% " - (stringp source) source) - (print-object (encapsulated-condition condition) stream))))) - -(def!method make-load-form ((condition compiled-program-error) &optional env) - (let ((source (program-error-source condition))) - ;; Safe since the encapsulated condition shouldn't contain - ;; references back up to the main condition. The source needs to - ;; be converted to a string, since it may contain arbitrary - ;; unexternalizable objects. - `(make-condition 'compiled-program-error - :condition ,(make-condition-load-form - (encapsulated-condition condition) env) - :source ,(if (stringp source) - source - (write-to-string - source :pretty t :circle t :escape t :readably nil))))) - -(define-condition make-load-form-error (encapsulated-condition error) - ((object :initarg :object :reader make-load-form-error-object)) - (:report (lambda (condition stream) - (let ((object (make-load-form-error-object condition))) - ;; If the MAKE-LOAD-FORM-ERROR itself has been - ;; externalized, the object will only have it's string - ;; representation. - (format stream "~@~% " - (stringp object) - object - 'make-load-form) - (print-object (encapsulated-condition condition) stream))))) - -(def!method make-load-form ((condition make-load-form-error) &optional env) - (let ((object (make-load-form-error-object condition))) - ;; Safe, because neither the object nor the encapsulated condition - ;; should contain any references to the error itself. However, the - ;; object will need to be converted to its string representation, - ;; since the chances are that it's not externalizable. - `(make-condition 'make-load-form-error - :condition ,(make-condition-load-form - (encapsulated-condition condition) env) - :object ,(if (stringp object) - object - (write-to-string - object :pretty t :circle t :escape t :readably nil))))) + (format stream "Execution of a form compiled with errors.~%~ + Form:~% ~A~%~ + Compile-time-error:~% ~A" + (program-error-source condition) + (program-error-message condition))))) (define-condition simple-control-error (simple-condition control-error) ()) (define-condition simple-file-error (simple-condition file-error) ()) diff --git a/src/compiler/compiler-error.lisp b/src/compiler/compiler-error.lisp index bd19505..ea8310c 100644 --- a/src/compiler/compiler-error.lisp +++ b/src/compiler/compiler-error.lisp @@ -111,12 +111,9 @@ (values)) (defun make-compiler-error-form (condition source) - ;; The condition must be literal so the this form kicks off the - ;; MAKE-LOAD-FORM in the file-compiler for COMPILED-PROGRAM-ERROR, - ;; not the encapsulated condition. - `(error ,(make-condition 'compiled-program-error - :condition condition - :source source))) + `(error 'compiled-program-error + :message ,(princ-to-string condition) + :source ,(princ-to-string source))) ;;; the condition of COMPILE-FILE being unable to READ from the ;;; source file diff --git a/src/compiler/main.lisp b/src/compiler/main.lisp index 83c67e3..74ab7bb 100644 --- a/src/compiler/main.lisp +++ b/src/compiler/main.lisp @@ -1695,9 +1695,7 @@ (handler-case (sb!xc:make-load-form constant (make-null-lexenv)) (error (condition) - (compiler-error 'make-load-form-error - :condition condition - :object constant))) + (compiler-error condition))) (case creation-form (:sb-just-dump-it-normally (fasl-validate-structure constant *compile-object*) diff --git a/tests/compiler.test.sh b/tests/compiler.test.sh index 0a4624c..48597b5 100644 --- a/tests/compiler.test.sh +++ b/tests/compiler.test.sh @@ -261,6 +261,31 @@ cat > $tmpfilename < $tmpfilename < $tmpfilename < $tmpfilename <