Skip to content

Commit

Permalink
cs: fix some predefined struct-operation procedure names
Browse files Browse the repository at this point in the history
  • Loading branch information
mflatt committed Dec 30, 2020
1 parent c7ca441 commit dbe3616
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
7 changes: 7 additions & 0 deletions pkgs/racket-test-core/tests/racket/name.rktl
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,11 @@
(test 'bytes-set! object-name bytes-set!)
(test 'bytes-length object-name bytes-length)

;; Check some primitive structure functions
(test 'date object-name date)
(test 'date* object-name date*)
(test 'date? object-name date?)
(test 'date*? object-name date*?)
(test 'date-second object-name date-second)

(report-errs)
18 changes: 11 additions & 7 deletions racket/src/cs/rumble/struct.ss
Original file line number Diff line number Diff line change
Expand Up @@ -1282,16 +1282,20 @@
(define name ctr-expr)
(define authentic-name? (record-predicate struct:name))
(define name? (|#%struct-predicate|
(lambda (v) (or (authentic-name? v)
(and (impersonator? v)
(authentic-name? (impersonator-val v)))))))
(|#%name|
name?
(lambda (v) (or (authentic-name? v)
(and (impersonator? v)
(authentic-name? (impersonator-val v))))))))
(define name-field
(let ([name-field (record-accessor struct:name field-index)])
(|#%struct-field-accessor|
(lambda (v)
(if (authentic-name? v)
(name-field v)
(pariah (impersonate-ref name-field struct:name field-index v 'name 'field))))
(|#%name|
name-field
(lambda (v)
(if (authentic-name? v)
(name-field v)
(pariah (impersonate-ref name-field struct:name field-index v 'name 'field)))))
struct:name
field-index)))
...
Expand Down

0 comments on commit dbe3616

Please sign in to comment.