[racket-dev] syntax-local-inferred-name, keyword functions, and syntax properties

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Mon Dec 9 16:10:17 EST 2013

Currently, this program fails with a somewhat bizarre type error:

    #lang typed/racket

    (: foo ([#:k Any] -> Integer))
    (define (foo #:k [s #f]) 0)

    (let: ([i : Integer (foo #:k #t)]) i)

The reason is that the expansion of keyword applications generates a
name to use for the function (here `foo`), and it uses
`syntax-local-infer-name` to get the name to use. Unfortunately, in
this case, it produces `i`, an identifier which has an extra syntax
property saying that `i` is an `Integer`.  Of course, `foo` isn't an
integer, it's a function, and so we get a type error.

I don't see why the inferred name is the right choice here -- there's
no connection between `i` and the name of the function. I can just
change this to use a fresh name, but I thought I'd ask first.

Sam

Posted on the dev mailing list.