[racket-dev] for/hash bug in typed racket?

From: John Clements (clements at brinckerhoff.org)
Date: Wed May 25 18:39:58 EDT 2011

To begin with: I was surprised and elated to discover that typed racket handles list comprehensions!

Now: the error I get on this code looks very much like a bug:

#lang typed/racket

(: tag->num-table (HashTable Symbol Integer))
(define tag->num-table
  (for/hash ([t (in-list '(a b c))] [i (in-naturals)]) (values t i)))


... yields this error text:

Welcome to DrRacket, version 5.1.1.5--2011-05-24(dcb5e89/g) [3m].
Language: typed/racket [custom]; memory limit: 256 MB.
. Type Checker: Polymorphic function hash-set could not be applied to arguments:
Argument 1:
  Expected: (HashTable a b)
  Given:    (HashTable Integer Integer)
Argument 2:
  Expected: a
  Given:    (U 'a 'b 'c)
Argument 3:
  Expected: b
  Given:    Integer
 in: (for/hash ((t (in-list (quote (a b c)))) (i (in-naturals))) (values t i))
. Type Checker: Expected (HashTable Symbol Integer), but got (HashTable Integer Integer) in: (for/hash ((t (in-list (quote (a b c)))) (i (in-naturals))) (values t i))
. Type Checker: Summary: 2 errors encountered in:
  (for/hash ((t (in-list (quote (a b c)))) (i (in-naturals))) (values t i))
  (for/hash ((t (in-list (quote (a b c)))) (i (in-naturals))) (values t i))


The suspicious thing here is that typed racket believes that this hash table maps Integers to Integers, rather than Symbols to Integers; I can't see any part of my code that would lead to this assumption.

John 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110525/2f337ebe/attachment.p7s>

Posted on the dev mailing list.