[racket] TR: mystery behavior with optional-argument types

From: Matthew Butterick (mb at mbtype.com)
Date: Sat Mar 21 22:29:21 EDT 2015

I want to typecheck a function that looks like f1. But it doesn't work. The types of 'bool' and 'syms' are reported as Any.

However, if I add a dummy keyword argument, as in f2, then everything typechecks fine: 'bool' is reported as a Boolean and 'syms' is (Listof Symbol).

Feature? Bug?

;;;;;;;;;;;;;;;;;;;;;;;

#lang typed/racket

(: f1 (() (Boolean) #:rest Symbol . ->* . Any))
(define (f1 [bool #t] . syms)
  bool
  syms)

(: f2 (() (Boolean #:x Integer) #:rest Symbol . ->* . Any))
(define (f2 [bool #t] #:x [x 42] . syms)
  bool
  syms)

Posted on the users mailing list.