leftmike / foment

Foment is an implementation of R7RS Scheme.
MIT License
67 stars 4 forks source link

assertion fails when running srfi-204 with pattern variables #36

Open fthibault1969 opened 4 years ago

fthibault1969 commented 4 years ago

The pattern matcher works on patterns that are only literals like: (match 2 (1 #t) (2 #f))

(match '(1 2 2) ((1 2 ...) 2))

but patterns with variables like:

(match '(1 2 2) ((a b ...) b))

crash with "assert IdentifierP(obj) (190)../src/synrules.cpp" and then a long column of numbers.

leftmike commented 4 years ago

Using the same library definition as gerbil looks like it works.

FYI, Foment allows you to mix library definitions and then code that imports and uses the library definition in the same file.

(define-library (srfi-204)
    (export match match-lambda match-lambda* match-let match-letrec match-let*
         ___ **1 =.. *.. *** ? $ struct object get!)
    (import (scheme base))
    (include "../../srfi-204/srfi/auxiliary-syntax.scm")
    (begin
      (define-auxiliary-keywords ___ **1 =.. *.. *** ? $ struct object get!))
    (include "../../srfi-204/srfi/srfi-204/srfi-204.scm"))

(import (foment base))
(import (srfi-204))

(write (match 2 (1 #t) (2 #f))) (newline)

(write (match '(1 2 2) ((1 2 ...) 2))) (newline)

(write (match '(1 2 2) ((a b ...) b))) (newline)
#f
2
(2 2)