Opened 11 years ago

Closed 11 years ago

#943 closed defect (fixed)

typed-records: defstruct breaks with default values

Reported by: megane Owned by: felix winkelmann
Priority: major Milestone: someday
Component: extensions Version: 4.8.x
Keywords: Cc:
Estimated difficulty:

Description

The expected output is shown in case 3. In this case the slot for 'a' is defined as (a : fixnum).

If the default is given the slot and accessor indices are reversed, and with -specialized just the slot indices are reversed.

(use typed-records)

(defstruct bar
  ((a 100) : fixnum)
  (b : fixnum))

(define (create-bar a)
  (let* [(b (make-bar a: a b: 42))]
    (print "(bar-a b) " (bar-a b))
    (print "(bar-b b) " (bar-b b))
    (print "(##sys#slot b 1) " (##sys#slot b 1))
    (print "(##sys#slot b 2) " (##sys#slot b 2))
    b))

(create-bar 1)

;; 1. no -specialize
;; (bar-a b) 1
;; (bar-b b) 42
;; (##sys#slot b 1) 42
;; (##sys#slot b 2) 1

;; 2. with -specialize
;; (bar-a b) 42
;; (bar-b b) 1
;; (##sys#slot b 1) 42
;; (##sys#slot b 2) 1

;; 3. without the default `100' for slot `a'
;; (bar-a b) 1
;; (bar-b b) 42
;; (##sys#slot b 1) 1
;; (##sys#slot b 2) 42

Change History (3)

comment:1 Changed 11 years ago by felix winkelmann

Owner: set to felix winkelmann
Status: newassigned

comment:2 Changed 11 years ago by felix winkelmann

Please try typed-records 0.4.

comment:3 Changed 11 years ago by megane

Resolution: fixed
Status: assignedclosed

It works now. Thank you.

Note: See TracTickets for help on using tickets.