From f1c68bd51a7940c9e047f38f8652728af7d0b45e Mon Sep 17 00:00:00 2001 From: Abhishek L Date: Thu, 5 Dec 2013 03:29:49 +0530 Subject: [PATCH] Allow macros to return None, fixes #357 Allows Hy macros to return None, to test this (defmacro foo []) (foo) Should work now --- hy/macros.py | 3 ++- tests/native_tests/native_macros.hy | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/hy/macros.py b/hy/macros.py index 20d0cac..d3f08d8 100644 --- a/hy/macros.py +++ b/hy/macros.py @@ -84,7 +84,8 @@ _wrappers = { complex: HyComplex, 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) + list: lambda l: HyList(_wrap_value(x) for x in l), + type(None): lambda foo: HySymbol("None"), } diff --git a/tests/native_tests/native_macros.hy b/tests/native_tests/native_macros.hy index f5b1b74..b9f1cf0 100644 --- a/tests/native_tests/native_macros.hy +++ b/tests/native_tests/native_macros.hy @@ -34,6 +34,9 @@ (defmacro a-dict [] {1 2}) (assert (= (a-dict) {1 2})) +(defmacro a-none []) +(assert (= (a-none) None)) + ; A macro calling a previously defined function (eval-when-compile (defn foo [x y]