[racket] clarification for a Typed Racket error?

From: Erik Silkensen (eriksilkensen at gmail.com)
Date: Fri Jan 6 02:24:50 EST 2012

Hi,

I was wondering if someone could help me understand the problem with the following code?

(struct: obj ([a : Integer] [b : Symbol]))

(: f1? (obj Symbol -> Boolean))
(define (f1? o x)
 (and (= 0 (obj-a o))
      (eq? x (obj-b o))))

(: f2? (obj Symbol -> Boolean))
(define (f2? o x)
 (and (zero? (obj-a o))
      (eq? x (obj-b o))))

(: f3? (obj Symbol -> Boolean))
(define (f3? o x)
 (and (eq? x (obj-b o))
      (zero? (obj-a o))))

It looks like f1 and f3 are ok, but f2 has the error "Type Checker: Expected obj, but got #(struct:#<syntax:3:9 obj> ((U Inexact-Complex Real-Zero) Symbol)) in: o".

Thanks,
Erik


Posted on the users mailing list.