Steel Bank Common Lisp

Wrong type assertion and load-time-value

Reported by Stas Boukarev on 2011-08-09
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Low
Unassigned

Bug Description

When compiling

(defvar *var* 10)
(declaim (fixnum *var*))

(defun foo ()
  (the list (load-time-value *var*)))

=>error:
    SB-KERNEL:NUMERIC-TYPE (supertype of SB-KERNEL:NUMERIC-TYPE) is not a DEF!STRUCT-defined type.

Which boils down to:
(defun foo ()
  (the list (sb-ext:truly-the #.(sb-kernel:make-numeric-type :class 'integer) 10)))

Another issue is that SBCL doesn't produce nor a compile-time, neither a load-time warning when compiling
(defun foo ()
  (the list (load-time-value 10)))
while it does produce it when just LOADing the .lisp

Stas Boukarev (stassats) on 2011-08-09
Changed in sbcl:
status: New → Confirmed
importance: Undecided → Low
Changed in sbcl:
assignee: nobody → Nikodemus Siivola (nikodemus)
status: Confirmed → In Progress
Nikodemus Siivola (nikodemus) wrote :

commit ed066199124c46998798122cc776e615c9c50372
Author: Nikodemus Siivola <email address hidden>
Date: Tue Aug 9 10:57:41 2011 +0300

    LOAD-TIME-VALUE improvements

     * Derive the type of :TOPLEVEL lambdas properly. Without this we were
       never able to utilize the type from COMPILE-LOAD-TIME-STUFF.

     * Use the source-type whenever it is more accurate than the type from
       COMPILE-LOAD-TIME-STUFF -- eg. when using a value cell.

     * Add ALIAS argument to IR1-CONVERT, allowing saving alternate forms
       into *CURRENT-PATH*: this allows

         (defparameter *var* 10)

         (compile nil '(lambda () (the list (load-time-value *var*))))

        to give the warning

          ; Derived type of *VAR* is
          ; (VALUES (INTEGER 10 10) &OPTIONAL),
          ; conflicting with its asserted type
          ; LIST.

        instead of the much less useful

          ; Constant 10 conflicts with its asserted type LIST.

      * Use THE-IN-POLICY directly in LOAD-TIME-VALUE, allowing the file-
        compiler to report the LOAD-TIME-VALUE form for type-conflicts
        instead of (TRULY-THE <type> (%LOAD-TIME-VALUE ...))

Changed in sbcl:
assignee: Nikodemus Siivola (nikodemus) → nobody
status: In Progress → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers