VALIDATE-SUPERCLASS: invalid error message when EQL-specializers are used

Bug #1809740 reported by Michał "phoe" Herda
2
Affects Status Importance Assigned to Milestone
SBCL
Invalid
Undecided
Unassigned

Bug Description

Let's create a class named FOO and explicitly prevent it from being subclassed via a method on VALIDATE-SUPERCLASS with an EQL-specializer.

CL-USER> (defclass foo () ())
#<STANDARD-CLASS COMMON-LISP-USER::FOO>

CL-USER> (defmethod sb-mop:validate-superclass
           ((class class) (superclass (eql (find-class 'foo))))
           nil)
#<STANDARD-METHOD SB-MOP:VALIDATE-SUPERCLASS
  (CLASS (EQL #<STANDARD-CLASS COMMON-LISP-USER::FOO>)) {100341B4C3}>

CL-USER> (defclass bar (foo) ())
; Error: The class #<STANDARD-CLASS FOO> was specified as a superclass of the
; class #<STANDARD-CLASS BAR {100371D223}>, but the metaclasses
; #<STANDARD-CLASS STANDARD-CLASS> and #<STANDARD-CLASS STANDARD-CLASS> are
; incompatible. Define a method for SB-MOP:VALIDATE-SUPERCLASS to avoid this
; error.

The error message suggests that STANDARD-CLASS is incompatible with itself, which is false in this specific case.

Sure, the case when most people want to define their own methods on VALIDATE-SUPERCLASS is when they attempt to define their own metaclasses, and that is when the error message is helpful, but VALIDATE-SUPERCLASS is a more generic function than "are these metaclasses compatible". The error message should take it into account.

Revision history for this message
Michał "phoe" Herda (phoe-krk) wrote (last edit ):

This bugticket is invalid, because the following form:

CL-USER> (defmethod sb-mop:validate-superclass
           ((class class) (superclass (eql (find-class 'foo))))
           nil)

runs afoul of CLHS 11.1.2.1.2 point 19 if FOO is a STANDARD-CLASS (which it is in this case).

Changed in sbcl:
status: New → Invalid
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.