How to write `length` in TypedRacket with inlined types?

Hi everyone,

I am sorry for the newbie question. I'm wondering why TypedRacket complains about the following implementation of length

#lang typed/racket

(define #:forall [T] (len [ l : (Listof T)] ) : Number
  (match l
    [(list) 0]
    [(list _ l ...) (+ 1 (len l))] ; <--- error is here (line 6)
  )
)

Error:

foo.rkt:6:26: Type Checker: missing type for identifier;
 consider adding a type annotation with `:'
  identifier: len
  in: len
  location...:
   foo.rkt:6:26
  context...:

What exactly is the type annotation that is missing? Isn't function len annotated with the return type?

FYI,

$ racket --version
Welcome to Racket v8.2 [cs].
2 Likes

Strangely, adding this type annotation placates the type checker:

(: len (∀ [T] (-> (Listof T) Number)))

I would have expected a type annotation as part of define to work the same way as providing the type annotation separately, so this seems like a bug to me. (@samth?)