From dda71763a569c3d56b6276c5f4d22e7522b070e3 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 26 Aug 2020 16:07:52 +0900 Subject: [PATCH] fixing or patterns with different ids in branches --- lib/chibi/match-test.sld | 1 + lib/chibi/match/match.scm | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/chibi/match-test.sld b/lib/chibi/match-test.sld index b40acd49..9e0074f3 100644 --- a/lib/chibi/match-test.sld +++ b/lib/chibi/match-test.sld @@ -31,6 +31,7 @@ (test "or empty" 'ok (match '(o k) ((or) 'fail) (else 'ok))) (test "or single" 'ok (match 'ok ((or x) 'ok))) (test "or double" 'ok (match 'ok ((or (? symbol? y) y) y))) + (test "or unbalanced" 1 (match 1 ((or (and 1 x) (and 2 y)) x))) (test "not" 'ok (match 28 ((not (a . b)) 'ok))) (test "pred" 'ok (match 28 ((? number?) 'ok))) (test "named pred" 29 (match 28 ((? number? x) (+ x 1)))) diff --git a/lib/chibi/match/match.scm b/lib/chibi/match/match.scm index a043a40a..82527ea8 100644 --- a/lib/chibi/match/match.scm +++ b/lib/chibi/match/match.scm @@ -531,7 +531,8 @@ (define-syntax match-gen-or (syntax-rules () ((_ v p g+s (sk ...) fk (i ...) ((id id-ls) ...)) - (let ((sk2 (lambda (id ...) (sk ... (i ... id ...))))) + (let ((sk2 (lambda (id ...) (sk ... (i ... id ...)))) + (id (if #f #f)) ...) (match-gen-or-step v p g+s (match-drop-ids (sk2 id ...)) fk (i ...)))))) (define-syntax match-gen-or-step