[racket] exn:fail:contract:variable id field

From: Casey Klein (clklein at eecs.northwestern.edu)
Date: Fri Apr 1 05:10:19 EDT 2011

What exactly is in the `id' field of a `exn:fail:contract:variable'
structure? It doesn't seem to be the symbolic name of the
not-yet-defined variable.

#lang racket

(define-syntax (m stx)
  (syntax-case stx ()
    [(_ x)
     (let ([y (datum->syntax #'fresh (syntax-e #'x) #'x)])
       #`(begin
           #,y
           (define #,y 1)))]))

(uncaught-exception-handler
 (λ (exn)
   (displayln (exn:fail:contract:variable-id exn))
   ((error-escape-handler))))

(m x) ; => x.6, not x



Posted on the users mailing list.