[racket] Another basic TR question

From: Sam Tobin-Hochstadt (samth at cs.indiana.edu)
Date: Fri Feb 14 13:42:11 EST 2014

On Fri, Feb 14, 2014 at 10:51 AM, Vincent St-Amour <stamourv at ccs.neu.edu> wrote:
>
>> And while I've got your attention...
>>
>> When I tried the same thing with a smaller limit, e.g.
>>
>> > (for/sum: : Flonum [[ii : Index 8]]
>> >  pi)
>>
>> I got not only the aforementioned complaint about Zero but also a
>> complaint that it expected Index, but got Byte (presumably it decided
>> 8 was small enough to fit into a byte, so everything in sight must be
>> a byte).  Which is especially puzzling since Byte is a subtype of
>> Index....
>
> You're correct, `Byte' is a subtype of `Index', which makes this error
> message nonsensical.

Indeed, this is nonsensical, and I don't think Vincent's explanation
is quite right -- this shouldn't ever happen.

When I try this program, I get:

-> (for/sum: : Flonum ([i : Index 8]) pi)
; readline-input:1:0: Type Checker: type mismatch
;   expected: Flonum
;   given: Zero
;   in: (for/sum: : Flonum ((i : Index 8)) pi)
; readline-input:1:21: Type Checker: type mismatch
;   expected: Byte
;   given: Index
;   in: i

The first error message is what you mentioned earlier, and the second
is more like what I'd expect, and what Vincent's workaround fixes.

If you really get the reverse error, please report a bug with exactly
the version and the program.

Thanks for using Typed Racket, and for reporting issues.

Sam

Posted on the users mailing list.