Identifier created by datum->syntax is refered incorrectly.

Create issue
Issue #105 resolved
Takashi Kato repo owner created an issue

This should raise an error.

(import (rnrs))

(define-syntax define/datum->syntax
  (lambda (x)
    (define (concat n1 n2)
      (string->symbol
       (string-append (symbol->string (syntax->datum n1))
              "-"
              (symbol->string (syntax->datum n2)))))
    (syntax-case x ()
      ((k name1 name2 var)
       (with-syntax ((name (datum->syntax #'k (concat #'name1 #'name2))))
     #'(define name var))))))

(define-syntax define/wrap
  (syntax-rules ()
    ((_ name1 name2 var)
     (define/datum->syntax name1 name2 var))))

(define/wrap n1 n2 'hoge)

n1-n2

Comments (3)

  1. Takashi Kato reporter

    To fix this, I think macro expander (or compiler) should create unique binding name. This is because an global identifier can be referred by raw symbol.

  2. Log in to comment