justinethier / husk-scheme

A full implementation of the Scheme programming language for the Haskell Platform.
http://justinethier.github.io/husk-scheme
MIT License
309 stars 28 forks source link

Bug of syntax-rules pattern matcher #166

Closed SaitoAtsushi closed 10 years ago

SaitoAtsushi commented 10 years ago

I found a bug in syntax-rules.

For example:

(import (scheme base) (scheme write))

(define-syntax foo
  (syntax-rules ()
    ((_ (p ... . r))
     'r)))

(display (foo (1 2 3 4)))

expected result

()

but, husk report error.

see 4.3.2 in R7RS.

P is of the form (P1 ... Pk Pe <ellipsis> Pm+1 ... Pn . Px) where E is a list or improper list of n elements, the first k of which match P1 through Pk, whose next m-k elements each match Pe, whose remaining n-m elements match Pm+1 through Pn, and whose nth and final cdr matches Px

n-m is zero in above example case.

justinethier commented 10 years ago

Thanks for the report!

This one will probably take longer than the others to fix, although I need to spend time looking into it in more detail...

justinethier commented 10 years ago

This is fixed on 317-dev, and will be included in the 3.17 release.