Opened 12 years ago

Closed 3 years ago

#231 closed defect (fixed)

DEFSTRUCT accessor functions overwrite accessors in :INCLUDEd structs

Reported by: ehuelsmann Owned by: not-assigned
Priority: major Milestone: 1.8.0
Component: libraries Version: 1.2.0-dev
Keywords: Cc:
Parent Tickets:

Description

Ralf Moeller reports:

The following file causes a problem in ABCL (1.1.0-dev-svn-14041) when compiled (!) and loaded.

(in-package cl-user)

(defstruct a (s1 nil))

(defstruct (b (:include a) (:conc-name foo-)) (s2 nil))

(defstruct (c (:include a) (:conc-name foo-)) (s3 nil))

(defun test ()

(let ((x (make-b :s1 1 :s2 2)))

(foo-s1 x)))

CL-USER(4): (test)
#<THREAD "interpreter" {2EF7D41F}>: Debugger invoked on condition of type SIMPLE-TYPE-ERROR

The value #<B {564434F7}> is not of type C.

Restarts:

0: TOP-LEVEL Return to top level.

[1] CL-USER(6): (lisp-implementation-version)
"1.1.0-dev-svn-14041"
[1] CL-USER(7):

The problem is that the defstruct declaration for c "overwrites" the accessor foo-s1 generated by defstruct b.
If foo-s1 is called for a b instance, the type assertions introduced by define-reader (and define-writer, see the
ABCL implementation for defstruct) cause the error described above.

Change History (17)

comment:1 Changed 12 years ago by ehuelsmann

My response to Ralf was:

Thanks for the report. I've been thinking about it and I think the best solution is even easier to code: when an included DEFSTRUCT already defines the same accessor, we should simply not define it again: the result will be that the accessor checks for structs of type 'A and all of its subtypes will be allowed.

I'll log a ticket to that extent and try to come up with the right change to defstruct.lisp. However, if you can submit a patch to that extent, that'd be most appreciated!

comment:2 Changed 12 years ago by ehuelsmann

Milestone: 1.1.01.2.0

clisp exhibits the same behaviour and the spec allows it (or at least, doesn't specify behaviour for it).

Pushing out to 1.2.0 - not a blocker for 1.1.0.

comment:3 Changed 11 years ago by Mark Evenson

Version: 1.2.0-dev

comment:4 Changed 11 years ago by Evenson Not Org

Milestone: 1.2.01.3.0

comment:5 Changed 10 years ago by Mark Evenson

Owner: changed from Mark Evenson to not-assigned
Status: newassigned

comment:6 Changed 10 years ago by Mark Evenson

Milestone: 1.3.02.0

Ticket retargeted after milestone closed

comment:7 Changed 10 years ago by Mark Evenson

Milestone: 2.02.0.0

Milestone renamed

comment:8 Changed 10 years ago by Mark Evenson

Milestone: 2.0.01.4.0

comment:9 Changed 8 years ago by Mark Evenson

Milestone: 1.4.01.5.0

Ticket retargeted after milestone closed

comment:10 Changed 7 years ago by Mark Evenson

Milestone: 1.5.01.6.0

Ticket retargeted after milestone closed

comment:11 Changed 4 years ago by Mark Evenson

Milestone: 1.6.01.6.1

Ticket retargeted after milestone closed

comment:12 Changed 4 years ago by Mark Evenson

Milestone: 1.6.11.6.2

Ticket retargeted after milestone closed

comment:13 Changed 4 years ago by Mark Evenson

Milestone: 1.6.21.7.0

comment:14 Changed 4 years ago by Mark Evenson

Milestone: 1.7.01.7.1

Ticket retargeted after milestone closed

comment:15 Changed 4 years ago by Mark Evenson

Milestone: 1.7.11.7.2

Ticket retargeted after milestone closed

comment:16 Changed 4 years ago by Mark Evenson

Milestone: 1.7.21.8.0

Milestone renamed

comment:17 Changed 3 years ago by Mark Evenson

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.