typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

In some cases the type named via `define-type` won't work.

Open NoahStoryM opened this issue 3 years ago • 0 comments

What version of Racket are you using?

v8.4 [cs]

What program did you run?

#lang typed/racket

(define-type Type (U Symbol List-Type))
(define-type List-Type (Pair 'List Types))

(define-type Types (Listof Type))

(for/list : Types ([i (in-list '(a b c d e))]) 'Any)

What should have happened?

'(Any Any Any Any Any)

If you got an error message, please include it here.

draft.rkt:8:0: Type Checker: Error in macro expansion -- insufficient type information to typecheck. please add more type annotations
  in: (for/list : Types ((i (in-list (quote (a b c d e))))) (quote Any))
  location...:
   draft.rkt:8:0
  context...:
   .../private/map.rkt:40:19: loop
   [repeats 1 more time]
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt:243:5
   .../private/runtime.rkt:89:23: fail-handler110
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:112:0: tc-expr/check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:393:0: single-value
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:79:0: tc-expr/t
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-app/tc-app-main.rkt:88:0: tc/app-regular
   .../private/runtime.rkt:80:24: temp667
   .../private/runtime.rkt:89:23: fail-handler110
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:112:0: tc-expr/check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:416:2: loop
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt:122:0: check-let-body
   .../private/runtime.rkt:89:23: fail-handler110
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:112:0: tc-expr/check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:393:0: single-value
   ...

More.

Following code works:

#lang typed/racket

(define-type Type (U Symbol List-Type))
(define-type List-Type (Pair 'List Types))

(define-type Types (Listof Type))

(for/list : (Listof Type) ([i (in-list '(a b c d e))]) 'Any)

NoahStoryM avatar Mar 09 '22 14:03 NoahStoryM