0.8.16.9:
[sbcl.git] / src / compiler / generic / interr.lisp
1 ;;;; This file defines all of the internal errors. How they are
2 ;;;; handled is defined in .../code/interr.lisp. How they are signaled
3 ;;;; depends on the machine.
4
5 ;;;; This software is part of the SBCL system. See the README file for
6 ;;;; more information.
7 ;;;;
8 ;;;; This software is derived from the CMU CL system, which was
9 ;;;; written at Carnegie Mellon University and released into the
10 ;;;; public domain. The software is in the public domain and is
11 ;;;; provided with absolutely no warranty. See the COPYING and CREDITS
12 ;;;; files for more information.
13
14 (in-package "SB!KERNEL")
15
16 (defun error-number-or-lose (name)
17   (or (position name sb!c:*backend-internal-errors* :key #'car)
18       (error "unknown internal error: ~S" name)))
19
20 ;;; FIXME: Having each of these error handlers be a full, named function
21 ;;; seems to contribute a noticeable amount of bloat and little value.
22 ;;; Perhaps we could just make a single error-handling function with a
23 ;;; big CASE statement inside it? Or at least implement the error handling
24 ;;; functions as closures instead of DEFUNs?
25 (eval-when (:compile-toplevel :execute)
26   (def!macro define-internal-errors (&rest errors)
27              (let ((info (mapcar (lambda (x)
28                                    (cons (symbolicate (first x) "-ERROR")
29                                          (second x)))
30                                  errors)))
31                `(progn
32                   (setf sb!c:*backend-internal-errors*
33                         ',(coerce info 'vector))
34                   nil))))
35
36 (define-internal-errors
37   (unknown
38    "unknown system lossage")
39   (object-not-fun
40    "Object is not of type FUNCTION.")
41   (object-not-list
42    "Object is not of type LIST.")
43   (object-not-bignum
44    "Object is not of type BIGNUM.")
45   (object-not-ratio
46    "Object is not of type RATIO.")
47   (object-not-single-float
48    "Object is not of type SINGLE-FLOAT.")
49   (object-not-double-float
50    "Object is not of type DOUBLE-FLOAT.")
51   #!+long-float
52   (object-not-long-float
53    "Object is not of type LONG-FLOAT.")
54   (object-not-simple-string
55    "Object is not of type SIMPLE-STRING.")
56   (object-not-fixnum
57    "Object is not of type FIXNUM.")
58   (object-not-vector
59    "Object is not of type VECTOR.")
60   (object-not-string
61    "Object is not of type STRING.")
62   (object-not-base-string
63    "Object is not of type BASE-STRING.")
64   (object-not-bit-vector
65    "Object is not of type BIT-VECTOR.")
66   (object-not-array
67    "Object is not of type ARRAY.")
68   (object-not-number
69    "Object is not of type NUMBER.")
70   (object-not-rational
71    "Object is not of type RATIONAL.")
72   (object-not-float
73    "Object is not of type FLOAT.")
74   (object-not-real
75    "Object is not of type REAL.")
76   (object-not-integer
77    "Object is not of type INTEGER.")
78   (object-not-cons
79    "Object is not of type CONS.")
80   (object-not-symbol
81    "Object is not of type SYMBOL.")
82   (undefined-fun
83    ;; FIXME: Isn't this used for calls to unbound (SETF FOO) too? If so, revise
84    ;; the name.
85    "An attempt was made to use an undefined FDEFINITION.")
86   (invalid-arg-count
87    "invalid argument count")
88   (bogus-arg-to-values-list
89    "bogus argument to VALUES-LIST")
90   (unbound-symbol
91    "An attempt was made to use an undefined SYMBOL-VALUE.")
92   (object-not-sap
93    "Object is not a System Area Pointer (SAP).")
94   (invalid-unwind
95    "attempt to RETURN-FROM a block that no longer exists")
96   (unseen-throw-tag
97    "attempt to THROW to a non-existent tag")
98   (division-by-zero
99    "division by zero")
100   (object-not-type
101    "Object is of the wrong type.")
102   (odd-key-args
103    "odd number of &KEY arguments")
104   (unknown-key-arg
105    "unknown &KEY argument")
106   (invalid-array-index
107    "invalid array index")
108   (wrong-number-of-indices
109    "wrong number of indices")
110   (object-not-simple-array
111    "Object is not of type SIMPLE-ARRAY.")
112   (object-not-signed-byte-32
113    "Object is not of type (SIGNED-BYTE 32).")
114   (object-not-unsigned-byte-32
115    "Object is not of type (UNSIGNED-BYTE 32).")
116   (object-not-complex
117    "Object is not of type COMPLEX.")
118   (object-not-complex-rational
119    "Object is not of type (COMPLEX RATIONAL).")
120   (object-not-complex-float
121    "Object is not of type (COMPLEX FLOAT).")
122   (object-not-complex-single-float
123    "Object is not of type (COMPLEX SINGLE-FLOAT).")
124   (object-not-complex-double-float
125    "Object is not of type (COMPLEX DOUBLE-FLOAT).")
126   #!+long-float
127   (object-not-complex-long-float
128    "Object is not of type (COMPLEX LONG-FLOAT).")
129   (object-not-weak-pointer
130    "Object is not a WEAK-POINTER.")
131   (object-not-instance
132    "Object is not a INSTANCE.")
133   (object-not-character
134    "Object is not a CHARACTER.")
135   (nil-fun-returned
136    "A function with declared result type NIL returned.")
137   (nil-array-accessed
138    "An array with element-type NIL was accessed.")
139   (layout-invalid
140    "Object layout is invalid. (indicates obsolete instance)")
141   (object-not-complex-vector
142    "Object is not a complex (non-SIMPLE-ARRAY) vector.")
143   .
144   #.(map 'list
145          (lambda (saetp)
146            (list
147             (symbolicate "OBJECT-NOT-" (sb!vm:saetp-primitive-type-name saetp))
148             (format nil "Object is not of type ~A."
149                     (specifier-type
150                      `(simple-array ,(sb!vm:saetp-specifier saetp) (*))))))
151          sb!vm:*specialized-array-element-type-properties*))
152