close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Opened 15 years ago

Closed 15 years ago

#26 closed defect (fixed)

slot-value type check

Reported by: Raymond Toy Owned by: Raymond Toy
Priority: minor Milestone:
Component: PCL Version: 2008-11
Keywords: pcl Cc:

Description

From cmucl-help, 2008-11-26

(defclass foo ()
  ((a :type fixnum)))

(defvar *object* (make-instance 'foo))

This works, even though the assigned value is not a fixnum:

(setf (slot-value *object* 'a) 3.5)    ;; this works like a charm

but with

(defmethod setslot ((foo foo) val)
    (setf (slot-value foo 'a) val))

We have

(setslot *object* 3.5) ;; triggers a type error

Change History (2)

comment:1 Changed 15 years ago by Raymond Toy

Component: CorePCL
Owner: changed from somebody to Raymond Toy
Summary: slto-value type checkslot-value type check

comment:2 Changed 15 years ago by Raymond Toy

Resolution: fixed
Status: newclosed

This is now fixed in the 2008-12 snapshot. (setf slot-value) should now signal an error if the new value is not of the correct type. Note that not all cases are handled now, but the common case from the repl works.

pcl::*use-slot-types-p* is also honored in that if it is NIL, the checking is disabled.

Note: See TracTickets for help on using tickets.