[racket] Why "reference to an identifier before its definition" in this program?

From: Eric Hanchrow (eric.hanchrow at gmail.com)
Date: Sun Dec 25 17:52:39 EST 2011

This is racket v5.2.

#lang racket

(define/contract (x input)
  (y . -> . any/c)
  3)

;; (define (x input)
;;   (y)
;;   3)

(define (y)
  #t)

When I run this, I get

racket ./hmm.rkt
reference to an identifier before its definition: y in module: ...

However, if I comment out the first definition of x, and uncomment the
second, I don't get an error.

What is the difference?  Is this a bug?  It'd be nice if I could use a
defined-later-in-the-file function in my contract; otherwise I have to
carefully order the functions in the file, which makes it harder to
read the file.


Posted on the users mailing list.