|
2 | 2 |
|
3 | 3 | (require (for-syntax racket/base |
4 | 4 | racket/format |
| 5 | + syntax/intdef |
| 6 | + threading |
5 | 7 |
|
6 | 8 | hackett/private/infix |
7 | 9 | hackett/private/typecheck |
|
28 | 30 | (make-variable-like-transformer type-template)] |
29 | 31 | [else |
30 | 32 | (syntax-parser |
31 | | - [(_ t:type ...) |
| 33 | + [(head:id t:type ...) |
32 | 34 | #:fail-unless (= (length (attribute t)) arity) |
33 | 35 | (~a "expected " arity " argument(s) to type alias, got " |
34 | 36 | (length (attribute t))) |
35 | | - (insts type-template (map cons args (attribute t)))] |
| 37 | + (for/fold ([result (insts type-template (map cons args (attribute t)))]) |
| 38 | + ([residual (in-list (attribute t.residual))]) |
| 39 | + (syntax-track-origin result residual #'head))] |
36 | 40 | [:id |
37 | 41 | #:fail-when #t (~a "expected " arity " argument(s) to type alias") |
38 | 42 | (error "unreachable")])]) |
|
53 | 57 | ; Expanding the type in `ctx` checks immediately that it is a valid type, |
54 | 58 | ; rather than deferring that check to when the type alias is applied. |
55 | 59 | #:with {~var type-template- (type intdef-ctx)} #'type-template |
56 | | - #'(begin |
57 | | - (define-values [] type-template-.residual) |
58 | | - (define-syntax ctor-spec*.tag |
59 | | - (make-alias-transformer |
60 | | - (list (quote-syntax arg*) ...) |
61 | | - (quote-syntax type-template-.expansion) |
62 | | - 'fixity)))]) |
| 60 | + (~>> #'(begin |
| 61 | + (define-values [] type-template-.residual) |
| 62 | + (define-syntax ctor-spec*.tag |
| 63 | + (make-alias-transformer |
| 64 | + (list (quote-syntax arg*) ...) |
| 65 | + (quote-syntax type-template-.expansion) |
| 66 | + 'fixity))) |
| 67 | + (internal-definition-context-track intdef-ctx))]) |
63 | 68 |
|
0 commit comments