From 3bcad308dba9cbe1ee6e66fc405e479c29992567 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 18 Jan 2022 07:50:17 -0800 Subject: quasiquote: make new @,expr work in dot position. Bugfix: the newly introduced @.expr fails in the dotted position because ^(a . @,expr) turns into (list 'a 'let ...). * eval.c (is_meta_unquote): New static function. (expand_qquote_rec): Replace existing shape test with is_meta_unquote. We must also use this test in one more place: whenever the cdr of a list has the meta unquote shape, we must treat the result similarly to a dotted atom, by converting to append format. * tests/010/qquote.tl: Test cases to cover this. --- tests/010/qquote.tl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/010/qquote.tl') diff --git a/tests/010/qquote.tl b/tests/010/qquote.tl index e6daad3a..26d5417b 100644 --- a/tests/010/qquote.tl +++ b/tests/010/qquote.tl @@ -9,15 +9,27 @@ (tree-bind (x y (op arg)) ^(a b @,sym) (assert (eq op 'sys:var)) (assert (eq arg sym))) + (tree-bind (x y . (op arg)) ^(a b . @,sym) + (assert (eq op 'sys:var)) + (assert (eq arg sym))) (tree-bind (x y (op arg)) ^(a b @,atom) (assert (eq op 'sys:var)) (assert (eq arg atom))) + (tree-bind (x y . (op arg)) ^(a b . @,atom) + (assert (eq op 'sys:var)) + (assert (eq arg atom))) (tree-bind (x y (op arg)) ^(a b @,cons) (assert (eq op 'sys:expr)) (assert (eq arg cons))) + (tree-bind (x y . (op arg)) ^(a b . @,cons) + (assert (eq op 'sys:expr)) + (assert (eq arg cons))) (tree-bind (x y (op arg)) ^(a b @,dwim) (assert (eq op 'sys:expr)) (assert (eq arg dwim))) + (tree-bind (x y . (op arg)) ^(a b . @,dwim) + (assert (eq op 'sys:expr)) + (assert (eq arg dwim))) (tree-bind (x y (op arg . tail)) ^(a b (sys:expr ,sym . foo)) (assert (eq op 'sys:expr)) (assert (eq arg sym)) -- cgit v1.2.3