From 9278b24318441571a17e1137067704f9ee9920d9 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Sun, 28 Jul 2013 00:38:16 +0200 Subject: [PATCH] Allow quoting lambda list keywords. This fixes an obvious bug where LambdaListKeywords couldn't be quoted. --- hy/__init__.py | 1 + hy/compiler.py | 2 +- tests/native_tests/quote.hy | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hy/__init__.py b/hy/__init__.py index ef0b8d6..3cb4c7b 100644 --- a/hy/__init__.py +++ b/hy/__init__.py @@ -24,6 +24,7 @@ __version__ = "0.9.10" from hy.models.expression import HyExpression # NOQA +from hy.models.lambdalist import HyLambdaListKeyword # NOQA from hy.models.integer import HyInteger # NOQA from hy.models.keyword import HyKeyword # NOQA from hy.models.complex import HyComplex # NOQA diff --git a/hy/compiler.py b/hy/compiler.py index 36af599..1fd3fd5 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -618,7 +618,7 @@ class HyASTCompiler(object): return imports, HyExpression([HySymbol(name), contents]).replace(form), False - elif isinstance(form, HySymbol): + elif isinstance(form, (HySymbol, HyLambdaListKeyword)): return imports, HyExpression([HySymbol(name), HyString(form)]).replace(form), False diff --git a/tests/native_tests/quote.hy b/tests/native_tests/quote.hy index 0b3e1d0..45c7648 100644 --- a/tests/native_tests/quote.hy +++ b/tests/native_tests/quote.hy @@ -75,3 +75,10 @@ (assert (= (len q) 3)) (assert (= (get qq 1) (quote (quasiquote (unquote (+ 1 5)))))) (assert (= q qq))) + + +(defn test-quote-lambdalistkeyword [] + "NATIVE: test quoting lambda list keywords" + (setv opt (quote &optional)) + (assert (isinstance opt hy.HyLambdaListKeyword)) + (assert (= (str opt) "&optional")))