|
10 | 10 | (types struct-table) |
11 | 11 | (utils tc-utils) |
12 | 12 | (env env-utils) |
| 13 | + (base-env type-name-error) |
13 | 14 | (for-syntax racket/base) |
14 | 15 | (for-template racket/base)) |
15 | 16 |
|
|
85 | 86 | (match-lambda |
86 | 87 | [(def-binding _ ty) |
87 | 88 | (mk-value-quad internal-id new-id ty)] |
88 | | - [(def-struct-stx-binding _ (? struct-info? si) constr-type) |
89 | | - (mk-struct-syntax-quad internal-id new-id si constr-type)] |
| 89 | + [(def-struct-stx-binding _ (? struct-info? si) constr-type extra-ctor-name) |
| 90 | + (mk-struct-syntax-quad internal-id new-id si constr-type extra-ctor-name)] |
90 | 91 | [(def-stx-binding _) |
91 | 92 | (mk-syntax-quad internal-id new-id)])] |
92 | 93 | ;; otherwise, not defined in this module, not our problem |
93 | 94 | [else (mk-ignored-quad internal-id)])) |
94 | 95 |
|
95 | 96 | ;; mk-struct-syntax-quad : identifier? identifier? struct-info? Type? -> quad/c |
96 | 97 | ;; This handles `(provide s)` where `s` was defined with `(struct s ...)`. |
97 | | - (define (mk-struct-syntax-quad internal-id new-id si constr-type) |
98 | | - (define type-is-constructor? #t) ;Conservative estimate (provide/contract does the same) |
| 98 | + (define (mk-struct-syntax-quad internal-id new-id si constr-type extra-ctor-name) |
99 | 99 | (match-define (list type-desc constr pred (list accs ...) muts super) (extract-struct-info si)) |
100 | 100 | (define-values (defns export-defns new-ids aliases) |
101 | 101 | (for/lists (defns export-defns new-ids aliases) |
102 | 102 | ([e (in-list (list* type-desc pred super accs))]) |
103 | 103 | (if (identifier? e) |
104 | 104 | (mk e) |
105 | 105 | (mk-ignored-quad e)))) |
| 106 | + |
| 107 | + (define type-is-constructor? (or (free-identifier=? new-id constr) extra-ctor-name)) |
106 | 108 | ;; Here, we recursively handle all of the identifiers referenced |
107 | 109 | ;; in this static struct info. |
108 | 110 | (define-values (constr-defn constr-export-defn constr-new-id constr-aliases) |
|
143 | 145 | (list #,@(map (lambda (x) #'#f) accs)) super*))) |
144 | 146 | #,(if type-is-constructor? |
145 | 147 | #'(make-struct-info-self-ctor constr* info) |
146 | | - #'info))) |
| 148 | + #'(lambda (stx) |
| 149 | + (type-name-error stx))))) |
147 | 150 | (define-syntax export-id |
148 | 151 | (make-rename-transformer #'protected-id))) |
149 | 152 | #'export-id |
|
0 commit comments