hoshom
2020-11-8 16:46:04

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?


hoshom
2020-11-8 16:47:38

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


michalbric
2020-11-8 19:42:52

@michalbric has joined the channel


sorawee
2020-11-9 00:01:39

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


343519265
2020-11-9 06:53:06

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