assumption-free-identifier-equal.rkt (973B)
1 #lang racket 2 (require rackunit) 3 (define-for-syntax outer #f) 4 (define-for-syntax inner #f) 5 6 (check-equal? (let ([x 1]) 7 (define-syntax (capture1 stx) 8 (set! outer #'x) 9 #'(void)) 10 (capture1) 11 (let ([x 2]) 12 (define-syntax (capture2 stx) 13 (set! inner #'x) 14 #'(void)) 15 (capture2) 16 (let ([y 3]) 17 (define-syntax (compare stx) 18 (define candidate (datum->syntax #'y 'x)) 19 ;; check that (datum->syntax #'y 'x) matches the 20 ;; inner x, but not the outer x, since they are already 21 ;; bound when the macro is executed. 22 #`(list #,(free-identifier=? candidate inner) 23 #,(free-identifier=? candidate outer))) 24 (compare)))) 25 '(#t #f))