struct: disallow #:extra-name with #:omit-define-syntaxes

This commit is contained in:
Matthew Flatt 2019-03-17 06:54:38 -06:00
parent ed2381ee59
commit f94fba12da
3 changed files with 7 additions and 1 deletions

View File

@ -180,7 +180,8 @@ If @racket[name-id] is supplied via @racket[#:extra-name] and it is
not @racket[id], then both @racket[name-id] and @racket[id] are bound
to information about the structure type. Only one of
@racket[#:extra-name] and @racket[#:name] can be provided within a
@racket[struct] form.
@racket[struct] form, and @racket[#:extra-name] cannot be combined
with @racket[#:omit-define-syntaxes].
@examples[#:eval posn-eval
(struct ghost (color name) #:prefab #:extra-name GHOST)

View File

@ -1193,6 +1193,9 @@
(test 'blinky ghost-name (struct-copy GHOST (ghost 'red 'blinky)))
(syntax-test #'GHOST)
(syntax-test #'(struct ghost (color name) #:extra-name GHOST #:omit-define-syntaxes)
"cannot be combined")
;; ----------------------------------------
;; Check `#:authentic`:

View File

@ -741,6 +741,8 @@
(lambda ()
(cond
[(and info-name (not name-only?))
(when omit-define-syntaxes?
(raise-syntax-error #f "#:extra-name cannot be combined with #:omit-define-syntaxes" stx))
; reuse existing value
(list #`(define-syntaxes (#,info-name) (syntax-local-value #'#,id)))]
[else null]))])