possible bug related to syntax-shift-phase-level

38 views
Skip to first unread message

Yongming Shen

unread,
Jul 27, 2019, 12:56:33 AM7/27/19
to Racket Users
Hi,

It seems that after an identifier has been shifted by syntax-shift-phase-level, the original identifier can bind the shifted identifier, but not the other way around. I think the correct behavior is that neither should bind the other. The following code can be used to test this.

(define-syntax bind-test0

  (lambda (stx)

    (define id #'x)

    (define shifted-id (syntax-shift-phase-level id -1))

    (syntax-case stx ()

      [(_ e)

        #`(let ([#,id e])

             (displayln #,shifted-id))])))


(define-syntax bind-test1

  (lambda (stx)

    (define id #'x)

    (define shifted-id (syntax-shift-phase-level id -1))

    (syntax-case stx ()

      [(_ e)

        #`(let ([#,shifted-id e])

             (displayln #,id))])))


(bind-test0 100) would display 100, but (bind-test1 100) would raise an error. I'm new to Racket, so if this is in fact the correct behavior, a pointer to some related documentation would be appreciated.


Thanks,

Yongming


Yongming Shen

unread,
Aug 2, 2019, 6:56:22 PM8/2/19
to Racket Users
Reply all
Reply to author
Forward
0 new messages