From 7d49e3e6f1422b3f9faa2e7f6f2e2e05c469ed1e Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 16 May 2019 10:05:54 -0400 Subject: [PATCH] Add unification to match macro. Using a quote on a symbol prevents the match macro from trying to create a binding to it, and instead tells it that we are binding to a symbol that is already in scope. --- Makefile | 2 +- src/boot/boot.janet | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 764837f5..d16b7ef9 100644 --- a/Makefile +++ b/Makefile @@ -252,7 +252,7 @@ dist: build/janet-dist.tar.gz build/janet-%.tar.gz: $(JANET_TARGET) \ src/include/janet.h src/include/janetconf.h \ - janet.1 LICENSE CONTRIBUTING.md $(JANET_LIBRARY) \ + janet.1 LICENSE CONTRIBUTING.md $(JANET_LIBRARY) $(JANET_STATIC_LIBRARY) \ build/doc.html README.md build/janet.c tar -czvf $@ $^ diff --git a/src/boot/boot.janet b/src/boot/boot.janet index dedd914e..f12cb96e 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -1127,10 +1127,13 @@ ~(if (= nil (def ,pattern ,expr)) ,sentinel ,(onmatch)))) (tuple? pattern) - (match-1 - (get pattern 0) expr - (fn [] - ~(if (and ,;(tuple/slice pattern 1)) ,(onmatch) ,sentinel)) seen) + (if (and (= (pattern 0) 'quote) (symbol? (pattern 1))) + # Unification with external values + ~(if (= ,(pattern 1) ,expr) ,(onmatch) ,sentinel) + (match-1 + (get pattern 0) expr + (fn [] + ~(if (and ,;(tuple/slice pattern 1)) ,(onmatch) ,sentinel)) seen)) (array? pattern) (do