Bug in Typed Racket

72 views
Skip to first unread message

Antonio Menezes Leitao

unread,
Nov 8, 2015, 7:16:46 AM11/8/15
to Racket Dev
Hi,

The following example works fine:

#lang racket

(define v (vector 1 2 3))
(for ([t (in-vector v 0 2)])
  (displayln t))

However, in Typed Racket, it does not:

Welcome to DrRacket, version 6.3.0.3--2015-11-06(58c919c/a) [3m].
Language: typed/racket; memory limit: 4096 MB.
. Type Checker: missing type for identifier;
 consider using `require/typed' to import it
  identifier: normalise-inputs
  from module: for.rkt in: (for ((t (in-vector v 0 2))) (displayln t))
. Type Checker: type mismatch
  expected: VectorTop
  given: Any in: (for ((t (in-vector v 0 2))) (displayln t))
. Type Checker: Summary: 2 errors encountered in:
  (for ((t (in-vector v 0 2))) (displayln t))
  (for ((t (in-vector v 0 2))) (displayln t))


Best,
António.

Sam Tobin-Hochstadt

unread,
Nov 8, 2015, 2:31:35 PM11/8/15
to Antonio Menezes Leitao, Racket Dev
Thanks for the report! I've got a fix here, which I'm still testing: https://github.com/racket/typed-racket/pull/238

Sam

--
You received this message because you are subscribed to the Google Groups "Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-dev+...@googlegroups.com.
To post to this group, send email to racke...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-dev/CAJQmiZWNoUkEB7bDyK9E5mUE3WdY40UC8eyTKnP4d5JwWjaKQw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Menezes Leitao

unread,
Nov 8, 2015, 4:31:58 PM11/8/15
to Sam Tobin-Hochstadt, Racket Dev
BTW, the following example typechecks:

(define #:forall (A) (foo [f : (Real -> A)] [b : Boolean]) : (Listof A)
  (list (f 0.1) (f 0.2)))

but the following example generates a lot of complaints:

(define #:forall (A) (foo [f : (Real -> A)] [b : Boolean #t]) : (Listof A)
  (list (f 0.1) (f 0.2)))

Welcome to DrRacket, version 6.3.0.3--2015-11-06(58c919c/a) [3m].
Language: typed/racket; memory limit: 4096 MB.
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: parse error in type;
 type name `A' is unbound in: A
. Type Checker: Summary: 8 errors encountered in:
  A
  A
  A
  A
  A
  A
  A
  A

Best,
António.

Sam Tobin-Hochstadt

unread,
Nov 9, 2015, 7:19:02 PM11/9/15
to Antonio Menezes Leitao, Racket Dev
On Sun, Nov 8, 2015 at 2:31 PM Sam Tobin-Hochstadt <sa...@cs.indiana.edu> wrote:
Thanks for the report! I've got a fix here, which I'm still testing: https://github.com/racket/typed-racket/pull/238

This is now fixed in the git source.

Sam Tobin-Hochstadt

unread,
Nov 9, 2015, 7:21:42 PM11/9/15
to Antonio Menezes Leitao, Racket Dev
Yes, there seems to be a bug with how type variables are scoped with `#:forall`. I recommend using this syntax, which works fine:

(: foo (All (A) (->* ((-> Real A)) (Boolean) (Listof A) )))
(define (foo f [b #t])
  (list (f 0.1) (f 0.2)))

But if you can open an issue on github for your program as well, that would be great.

Sam

On Sun, Nov 8, 2015 at 4:32 PM Antonio Menezes Leitao <antonio.men...@ist.utl.pt> wrote:
BTW, the following example typechecks:

(define #:forall (A) (foo [f : (Real -> A)] [b : Boolean]) : (Listof A)
  (list (f 0.1) (f 0.2)))

but the following example generates a lot of complaints:

(define #:forall (A) (foo [f : (Real -> A)] [b : Boolean #t]) : (Listof A)
  (list (f 0.1) (f 0.2)))

Welcome to DrRacket, version 6.3.0.3--2015-11-06(58c919c/a) [3m].
Language: typed/racket; memory limit: 4096 MB.
Reply all
Reply to author
Forward
0 new messages