﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
1804	compare doesn't compare if name is already bound	Idiomdrottning		"{{{
(define-syntax frob-bad
  (ir-macro-transformer
   (lambda (exp inject compare)
     (let ((body (cdr exp)))
       `',(let desc ((friends '()) (body body))
	   (cond
	    ((null? body)
	     friends)
	    ((pair? body) (append (desc friends (car body)) (desc friends (cdr body))))
	    ((any (cut compare body <>) '(x y z rest args))
	     (cons (strip-syntax body) friends))
	    (else '())))))))


(equal?
 ((lambda (x) (frob-bad (reverse x))) 'foo) ; unexpected behavior. Since x is bound in the scope.
 ((lambda (p) (frob-bad (reverse x))) 'foo) ; expected behavior. Since x is not bound in the scope.
)
 
(define-syntax frob-good
  (ir-macro-transformer
   (lambda (exp inject compare)
     (let ((body (cdr exp)))
       `',(let desc ((friends '()) (body body))
	    (cond
	     ((null? body)
	      friends)
	     ((pair? body) (append (desc friends (car body)) (desc friends (cdr body))))
	     ((memq (strip-syntax body) '(x y z rest args))
	      (cons (strip-syntax body) friends))
	     (else '())))))))

(equal?
 ((lambda (x) (frob-good (reverse x))) 'foo) ; working workaround by eq? after strip-syntax instead of compare
 ((lambda (p) (frob-good (reverse x))) 'foo))
}}}"	defect	closed	major	someday	expander	5.2.0	invalid			medium
