
Using racket cs 7.9,
This works: #lang racket
(define foo%
  (class object%
    (init unit)
    (super-new)
    (define _unit unit)
    (define/public (get-unit) _unit)))
(new foo% [unit "kg"]) But the following doesn’t: #lang typed/racket
(define foo%
  (class object%
    (init [unit : String])
    (super-new)
    (: _unit String)
    (define _unit unit)
    (: get-unit (-> String))
    (define/public (get-unit) _unit)))
(new foo% [unit "kg"]) Giving this error: unit: bad syntax in: unit
Renaming unit to bar works in the typed/racket version.
Is this a bug?

Also, switching to typed/racket/base works, too.

@michalbric has joined the channel

@hoshom that does look like a bug. unit seems to have an incorrect scope?

Yet another bug from early local expansion of expression positions. A workaround is (define _unit (#%expression unit)) .