Skip to content

Commit 33f4d63

Browse files
committed
Improve disappeared-use/disappeared-binding tracking for type aliases
1 parent ff3e5a1 commit 33f4d63

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

hackett-lib/hackett/private/type-alias.rkt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
(require (for-syntax racket/base
44
racket/format
5+
syntax/intdef
6+
threading
57

68
hackett/private/infix
79
hackett/private/typecheck
@@ -28,11 +30,13 @@
2830
(make-variable-like-transformer type-template)]
2931
[else
3032
(syntax-parser
31-
[(_ t:type ...)
33+
[(head:id t:type ...)
3234
#:fail-unless (= (length (attribute t)) arity)
3335
(~a "expected " arity " argument(s) to type alias, got "
3436
(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))]
3640
[:id
3741
#:fail-when #t (~a "expected " arity " argument(s) to type alias")
3842
(error "unreachable")])])
@@ -53,11 +57,12 @@
5357
; Expanding the type in `ctx` checks immediately that it is a valid type,
5458
; rather than deferring that check to when the type alias is applied.
5559
#: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))])
6368

0 commit comments

Comments
 (0)