Ticket #872 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

non-standard type of warning for shadowed clauses in typecase

Reported by: agrostis Owned by: gb
Priority: normal Milestone:
Component: ANSI CL Compliance Version: trunk
Keywords: Cc: cl-json-devel@…

Description

The definition of TYPECASE, ETYPECASE and CTYPECASE in the standard (CLHS §5.3) allows that there be multiple clauses specifying a matching type. If a clause is completely shadowed by earlier clauses, the compiler may issue a warning. The type of the warning is explicitly mentioned to be STYLE-WARNING. The exact wording is as follows:

The compiler may choose to issue a warning of type style-warning if a clause will never be selected because it is completely shadowed by earlier clauses.

However, CCL issues a SIMPLE-WARNING in such situations, e. g.:

(block nil
  (handler-bind ((warning (lambda (w) (return (type-of w)))))
    (macroexpand '(typecase nr
                    (long-float #\L) 
                    (double-float #\D)
                    (short-float #\S)
                    (t #\E)))))
⇒ SIMPLE-WARNING

Which, I believe, contradicts the above disposition of the standard. One consequence is that, with ASDF, such a warning issued during the compilation of a file makes COMPILE-OP fail, signalling an error where, in fact, there should be none.

Change History

comment:1 Changed 3 years ago by agrostis

To make the nature of warning more evident:

(block nil
  (handler-bind ((warning (lambda (w) (warn w) (return (type-of w)))))
    (macroexpand '(typecase nr
                    (long-float #\L) 
                    (double-float #\D)
                    (short-float #\S)
                    (t #\E)))))
≫ ; Warning: Clause (DOUBLE-FLOAT #\D) ignored in TYPECASE form - shadowed by (LONG-FLOAT #\L) .
≫ ; While executing: #<Anonymous Function #x86E4E5E>, in process listener(1).
⇒ SIMPLE-WARNING

comment:2 Changed 3 years ago by gb

  • Owner set to gb
  • Status changed from new to assigned

comment:3 Changed 3 years ago by gb

  • Status changed from assigned to closed
  • Resolution set to fixed

(In [14850]) If [E|C]TYPECASE warns about a shadowed clause, it has to be a STYLE-WARNING.

Fixes ticket:872 in the trunk.

Note: See TracTickets for help on using tickets.