From b97e0258e16a003bd7e081612987ecdc8bef19c8 Mon Sep 17 00:00:00 2001 From: James King Date: Wed, 19 Feb 2014 00:09:37 -0500 Subject: [PATCH] Fix for #497 One would expect the form: > (defmacro a (&rest b) b) > (a 1 2) To return a tuple object but we have no Hy model so it returns a HyList. Not sure if this is the right thing to do. --- hy/macros.py | 1 + tests/native_tests/native_macros.hy | 3 +++ 2 files changed, 4 insertions(+) diff --git a/hy/macros.py b/hy/macros.py index b155799..cf994a2 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -115,6 +115,7 @@ _wrappers = { str_type: HyString, dict: lambda d: HyDict(_wrap_value(x) for x in sum(d.items(), ())), list: lambda l: HyList(_wrap_value(x) for x in l), + tuple: lambda t: HyList(_wrap_value(x) for x in t), type(None): lambda foo: HySymbol("None"), } diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index dc5715d..5bdf821 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -31,6 +31,9 @@ (defmacro a-list [] [1 2]) (assert (= (a-list) [1 2])) +(defmacro a-tuple [&rest b] b) +(assert (= (a-tuple 1 2) [1 2])) + (defmacro a-dict [] {1 2}) (assert (= (a-dict) {1 2}))