#<SB-KERNEL:NAMED-TYPE NIL> fell through ETYPECASE expression.

Bug #1730434 reported by Paul F. Dietz on 2017-11-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Undecided
Unassigned

Bug Description

(compile nil
 '(lambda (a b)
   (declare (optimize (compilation-speed 0)
             (space 2)(debug 2) (safety 1) (speed 1)))
   (block b8
     (labels ((%f17
                  (&optional (f17-1 (return-from b8 1))
                             (f17-2 (if t (return-from b8 2) b))
                             (f17-3 3)
                             &key &allow-other-keys)
                (return-from b8 0)))
       (loop for lv3 below 2 count
            (if (if (equal b (%f17 0 a))
                        0
                        t)
                    (%f17 lv3 0 0)
                    (if (%f17 0)
                        nil
                        t)))
       ))))

===>

#<SB-KERNEL:NAMED-TYPE NIL> fell through ETYPECASE expression.
Wanted one of (SB-KERNEL:ARRAY-TYPE SB-KERNEL:UNION-TYPE
               SB-KERNEL:INTERSECTION-TYPE
               SB-KERNEL:MEMBER-TYPE).
   [Condition of type SB-KERNEL:CASE-FAILURE]

Restarts:
 0: [ABORT] Exit debugger, returning to top level.

Backtrace:
  0: ((LABELS SB-KERNEL::DETERMINE :IN SB-KERNEL:CTYPE-ARRAY-SPECIALIZED-ELEMENT-TYPES) #<SB-KERNEL:NAMED-TYPE NIL>)
  1: (SB-KERNEL:CTYPE-ARRAY-SPECIALIZED-ELEMENT-TYPES #<SB-KERNEL:NAMED-TYPE NIL>)
  2: ((FLET SB-C::NON-EQUAL-ARRAY-P :IN "SYS:SRC;COMPILER;SRCTRAN.LISP") #<SB-KERNEL:NAMED-TYPE NIL>)
  3: ((SB-C:DEFTRANSFORM EQUAL) #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME EQUAL :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL-FUN..
  4: (SB-C::IR1-TRANSFORM #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME EQUAL :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBAL-FUNCTION ..
  5: (SB-C::IR1-OPTIMIZE-COMBINATION #<SB-C::COMBINATION :FUN #<SB-C::REF :LEAF #<SB-C::GLOBAL-VAR :%SOURCE-NAME EQUAL :TYPE #1=#<SB-KERNEL:FUN-TYPE #> :DEFINED-TYPE #1# :WHERE-FROM :DECLARED :KIND :GLOBA..
  6: (SB-C::IR1-OPTIMIZE-BLOCK #<SB-C::CBLOCK 15 :START c1 {100745E813}>)
  7: (SB-C::IR1-OPTIMIZE #<SB-C:COMPONENT :NAME (LABELS %F17 :IN B8) :REANALYZE T {1007464BE3}> NIL)
  8: (SB-C::IR1-OPTIMIZE-UNTIL-DONE #<SB-C:COMPONENT :NAME (LABELS %F17 :IN B8) :REANALYZE T {1007464BE3}>)
  9: (SB-C::IR1-PHASES #<SB-C:COMPONENT :NAME (LABELS %F17 :IN B8) :REANALYZE T {1007464BE3}>)
 10: (SB-C::COMPILE-COMPONENT #<SB-C:COMPONENT :NAME (LABELS %F17 :IN B8) :REANALYZE T {1007464BE3}>)
[...]

Somewhat simplified:

(compile nil
  '(lambda (a b c)
   (declare (optimize (compilation-speed 0)
             (space 2)(debug 2) (safety 1) (speed 1)))
   (block b8
     (labels ((%f17
                  (&optional (f17-1 (return-from b8 1))
                             (f17-2 (if t (return-from b8 2) b))
                             (f17-3 3)
                             &key &allow-other-keys)
                (return-from b8 0)))
       (dolist (x c)
         (if (if (equal b (%f17 0 a)) 0 nil)
             (%f17 4 5 6)
             (if (%f17 0) nil t)))))))

Paul F. Dietz (paul-f-dietz) wrote :

More simplified. Order of args to EQUAL does not matter:

(compile nil
  '(lambda (b c)
    (declare (optimize (debug 2)))
    (block b8
      (labels ((%f
                   (&optional (f1 (return-from b8 1))
                              (f2 (if t (return-from b8 2) 5))
                              (f3 3)
                              &rest r)
                 (declare (ignore f1 f2 f3 r))
                 (return-from b8 0)))
        (dolist (x c)
          (declare (ignore x))
          (if (equal 17 (%f 0 1))
              (%f 4 5 6)
              (%f 7)
              ))))))

Paul F. Dietz (paul-f-dietz) wrote :

And simpler. Oddly, it stops failing if the unused B parameter is removed.

compile nil
  '(lambda (b c)
    (declare (optimize (debug 2)))
    (declare (ignore b))
    (block b8
      (labels ((%f
                   (&optional (f1 (return-from b8 1))
                              (f2 (if t (return-from b8 2) 5))
                              (f3 3)
                              &rest r)
                 (declare (ignore f1 f2 f3 r))
                 (return-from b8 0)))
        (dolist (x c)
          (declare (ignore x))
          (equal 17 (%f 0 1))
          (%f 4 5 6)
          (%f 7)
          )))))

Stas Boukarev (stassats) wrote :

Further simplified to
(lambda ()
  (declare (optimize (debug 2)))
  (block b8
    (labels ((%f17 (&optional (f17-1 (return-from b8 1))
                              (f17-2 (if t (return-from b8 2)))
                              f17-3
                    &rest args)
               (return-from b8 0)))
      (let (x)
        (equal 10 (%f17 0 3))
        (%f17 123 0 0)
        (%f17 0)
        x))))

Stas Boukarev (stassats) wrote :

3ea40926f24559dda2655b6236596a7aca39bb58

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

Other bug subscribers