Does not report type violations for code that would have been reported as unreachable

Bug #1909883 reported by Michael Fiano
6
This bug affects 1 person
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.

Revision history for this message
Stas Boukarev (stassats) wrote :

42 doesn't have an identity, so it can't be uniquely identified as being part of the initial source code.

Changed in sbcl:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.