diff --git a/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl b/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl index 7d325b5b..c436b0f9 100644 --- a/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl +++ b/typed-racket-doc/typed-racket/scribblings/reference/special-forms.scrbl @@ -382,7 +382,9 @@ those functions. (struct maybe-type-vars name-spec ([f : t] ...) options ...) ([maybe-type-vars code:blank (v ...)] [name-spec name (code:line name parent)] - [options #:transparent #:mutable #:prefab])]{ + [options #:transparent #:mutable #:prefab + (code:line #:constructor-name constructor-id) + (code:line #:extra-constructor-name constructor-id)])]{ Defines a @rtech{structure} with the name @racket[name], where the fields @racket[f] have types @racket[t], similar to the behavior of @|struct-id| from @racketmodname[racket/base]. diff --git a/typed-racket-test/fail/struct-extra-constructor.rkt b/typed-racket-test/fail/struct-extra-constructor.rkt new file mode 100644 index 00000000..87edd1a5 --- /dev/null +++ b/typed-racket-test/fail/struct-extra-constructor.rkt @@ -0,0 +1,8 @@ +#; +(exn-pred "define-struct: expected typed structure type options") +#lang typed/racket/base + +(define-struct foo () + ;; can't have both of these + #:constructor-name foo-cn + #:extra-constructor-name foo-ecn) diff --git a/typed-racket-test/succeed/struct-options.rkt b/typed-racket-test/succeed/struct-options.rkt new file mode 100644 index 00000000..e8ffa8ae --- /dev/null +++ b/typed-racket-test/succeed/struct-options.rkt @@ -0,0 +1,15 @@ +#lang typed/racket/base + +;; Tests for constructor options for struct + +(struct s1 ([x : Integer]) #:constructor-name cons-s1) +(define-struct s2 ([x : Integer]) #:constructor-name cons-s2) +(struct s3 ([x : Integer]) #:extra-constructor-name cons-s3) +(define-struct s4 ([x : Integer]) #:extra-constructor-name cons-s4) + +(cons-s1 1) +(cons-s2 2) +(s3 3) +(cons-s3 3) +(s4 4) +(cons-s4 4)