Does not report type violations for code that would have been reported as unreachable
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
The following does not report that 42 is not of type string:
(declaim (ftype (function () string) foo))
(defun foo ()
(declare (optimize speed))
(loop)
42)
The derived type is NIL, so this is expected. However it does report a DCE for:
(declaim (ftype (function () string) foo))
(defun foo ()
(declare (optimize speed))
(loop)
'(42))
At first I thought SBCL was omitting the return type checking for simple literal types, but:
(declaim (ftype (function () string) foo))
(defun foo ()
(declare (optimize speed))
(loop :while t
:do (when (= (random 10) 1) (loop-finish)))
42)
reports the type problem as expected.
I think there are two issues here:
1) not reporting unreachable code
2) not reporting type violations for code that would have been reported as unreachable
This violates the principle of least surprise because SBCL in most cases warns about unreachable code.
42 doesn't have an identity, so it can't be uniquely identified as being part of the initial source code.