From 289586b340c9fc2f18acd68e7f10e132f40ee1a3 Mon Sep 17 00:00:00 2001 From: Paul Tagliamonte Date: Tue, 18 Jun 2013 22:57:51 -0400 Subject: [PATCH] Adding back in keywords. Yes, I'm your hero, @algernon --- hy/compiler.py | 9 +++++++++ tests/native_tests/language.hy | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/hy/compiler.py b/hy/compiler.py index ed8ddb3..2e63ec2 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -1399,10 +1399,19 @@ class HyASTCompiler(object): return ret + @checkargs(1) + def _compile_keyword_call(self, expression): + expression.append(expression.pop(0)) + expression.insert(0, HySymbol("get")) + return self.compile(expression) + @builds(HyExpression) def compile_expression(self, expression): fn = expression[0] func = None + if isinstance(fn, HyKeyword): + return self._compile_keyword_call(expression) + if isinstance(fn, HyString): ret = self.compile_atom(fn, expression) if ret: diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 07ed7db..41de1dc 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -732,3 +732,8 @@ (defn test-encoding-nightmares [] "NATIVE: test unicode encoding escaping crazybits" (assert (= (len "ℵℵℵ♥♥♥\t♥♥\r\n") 11))) + + +(defn test-keyword-dict-access [] + "NATIVE: test keyword dict access" + (assert (= "test" (:foo {:foo "test"}))))