File tree Expand file tree Collapse file tree 2 files changed +31
-13
lines changed
typed-racket-lib/typed-racket/typecheck Expand file tree Collapse file tree 2 files changed +31
-13
lines changed Original file line number Diff line number Diff line change 364
364
365
365
(define extra-constructor (struct-names-extra-constructor names))
366
366
367
+ (define constructor-type (poly-wrapper (->* all-fields poly-base)))
368
+
367
369
(define constructor-binding
368
370
(make-def-binding (struct-names-constructor names)
369
- (poly-wrapper (->* all-fields poly-base))))
370
- (define constructor-bindings
371
- (cons constructor-binding
372
- (if extra-constructor
373
- (list (make-def-binding extra-constructor
374
- (poly-wrapper (->* all-fields poly-base))))
375
- null)))
371
+ constructor-type))
372
+
373
+ (define-values (constructor-bindings bindings^)
374
+ (let ([extra-constructor-bindings
375
+ (if extra-constructor (list (make-def-binding extra-constructor
376
+ constructor-type))
377
+ null)])
378
+ (values (cons constructor-binding extra-constructor-bindings)
379
+ (append (cons (make-def-struct-stx-binding (struct-names-type-name names)
380
+ si
381
+ (def-binding-ty constructor-binding))
382
+ extra-constructor-bindings)
383
+ bindings))))
376
384
377
385
(for ([b (in-list (append constructor-bindings bindings))])
378
386
(register-type (binding-name b) (def-binding-ty b)))
379
-
387
+
380
388
(append
381
- (if (free-identifier=? (struct-names-type-name names)
382
- (struct-names-constructor names))
389
+ (if (free-identifier=? (struct-names-type-name names)
390
+ (struct-names-constructor names))
383
391
null
384
392
(list constructor-binding))
385
- (cons
386
- (make-def-struct-stx-binding (struct-names-type-name names) si (def-binding-ty constructor-binding))
387
- bindings)))
393
+ bindings^))
388
394
389
395
390
396
Original file line number Diff line number Diff line change
1
+ #;
2
+ (exn-pred #rx"make-my-struct: contract violation\n expected: natural? " )
3
+ #lang racket
4
+
5
+ (module class-helpers typed/racket
6
+ (provide make-my-struct)
7
+
8
+ (struct my-struct ([a : Natural])
9
+ #:extra-constructor-name make-my-struct))
10
+
11
+ (require 'class-helpers )
12
+ (make-my-struct 'hi )
You can’t perform that action at this time.
0 commit comments