Ticket #444: ir-fix.patch

File ir-fix.patch, 1.6 KB (added by sjamaan, 13 years ago)

Fix for IR renaming bug

  • expand.scm

    diff --git a/expand.scm b/expand.scm
    index ad3130b..a23c8ec 100644
    a b  
    770770             (lambda (a)
    771771               (cond ((symbol? a)
    772772                      (dd `(RENAME/LOOKUP: ,sym --> ,a))
     773                      (set! renv (cons (cons sym a) renv))
    773774                      a)
    774775                     (else
    775776                      (let ((a2 (macro-alias sym se)))
     
    824825                r)
    825826            ")")
    826827        r))
     828    (define (assq-reverse s l)
     829      (cond
     830       ((null? l) #f)
     831       ((eq? (cdar l) s) (car l))
     832       (else (assq-reverse s (cdr l)))))
    827833    (define (mirror-rename sym)
    828834      (cond ((pair? sym)
    829835             (cons (mirror-rename (car sym)) (mirror-rename (cdr sym))))
     
    836842                      (lambda (name)
    837843                        (dd "STRIP SYNTAX ON " sym " ---> " name)
    838844                        name))
     845                     ((assq-reverse sym renv) =>
     846                      (lambda (a)
     847                        (dd "REVERSING RENAME: " sym " --> " (car a)) (car a)))
    839848                     ((not renamed)
    840849                      (dd "IMPLICITLY RENAMED: " sym) (rename sym))
    841850                     ((pair? renamed)
  • tests/syntax-tests.scm

    diff --git a/tests/syntax-tests.scm b/tests/syntax-tests.scm
    index 49aafcb..5228ded 100644
    a b  
    579579      (1 ==> (lambda (x) x))
    580580      (else 'yep))))
    581581
     582;; Literal quotation of a symbol, injected or not, should always result in that symbol
     583(module ir-se-test (run)
     584  (import chicken scheme)
     585  (define-syntax run
     586    (ir-macro-transformer
     587     (lambda (e i c)
     588       `(quote ,(i 'void))))))
     589
     590(import ir-se-test)
     591(t 'void (run))
    582592
    583593;;; local definitions
    584594