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

From: Alexis King (lexi.lambda at gmail.com)
Date: Sat Mar 21 22:35:55 EDT 2015

This feels eerily familiar to a very similar bug I found just yesterday, which I’ve reported here:
https://github.com/racket/typed-racket/issues/56 <https://github.com/racket/typed-racket/issues/56>

Something about this is definitely very broken. For the first function, f1, it “typechecks” even if you change the Boolean type to, for example, String, so it seems the type is just being completely ignored. I’m not sure why.

> On Mar 21, 2015, at 19:29, Matthew Butterick <mb at mbtype.com> wrote:
> 
> 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)
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20150321/205b14a5/attachment.html>

Posted on the users mailing list.