pereckerdal/blackhole — Issue #38: syntax-rules bug
Author: alvatarc
Created: 2012-02-22 09:00:46+00:00
State: open

This macro (taken from srfi-67) isn't expanding properly:

(define-syntax if3
(syntax-rules ()
((if3 c less equal greater)
(case c
((-1) less)
(( 0) equal)
(( 1) greater)
(else (error "comparison value not in {-1,0,1}"))))))

(define test '(let ((x -1) (y 0))
(if3 (let ((x0 x)) (set! x (+ x 1)) x0)
(begin (set! y (+ y 1)) y)
(begin (set! y (+ y 10)) y)
(begin (set! y (+ y 100)) y))))

; In REPL:
(expand-macro test)
=>
(let ((1#x -1) (2#y 0)) (set! 2#y (+ 2#y 1)) 2#y)

; This isn't correct, the expansion should include the case and its clauses.