From 049c78f5d5c08cabc5ae23b54f7e2229fcefaad8 Mon Sep 17 00:00:00 2001 From: gilch Date: Wed, 2 May 2018 19:50:43 -0600 Subject: [PATCH] Fix bug in let's handle-dot. --- hy/contrib/walk.hy | 6 ++++-- tests/native_tests/contrib/walk.hy | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/hy/contrib/walk.hy b/hy/contrib/walk.hy index 507cf42..b50ace8 100644 --- a/hy/contrib/walk.hy +++ b/hy/contrib/walk.hy @@ -136,12 +136,14 @@ Arguments without a header are under None. :quote-level (+ self.quote-level x)))) (defn handle-dot [self] - `(. ~@(walk (fn [form] + `(. ~(self.expand-symbols (first (self.tail))) + ~@(walk (fn [form] (if (symbol? form) form ; don't expand attrs (self.expand-symbols form))) identity - (self.tail)))) + (cut (self.tail) + 1)))) (defn head [self] (first self.form)) diff --git a/tests/native_tests/contrib/walk.hy b/tests/native_tests/contrib/walk.hy index b062186..e2d7a2a 100644 --- a/tests/native_tests/contrib/walk.hy +++ b/tests/native_tests/contrib/walk.hy @@ -227,7 +227,12 @@ (setv foo (fn []) foo.a 42) (let [a 1 - b []] + b [] + bar (fn [])] + (setv bar.a 13) + (assert (= bar.a 13)) + (setv (. bar a) 14) + (assert (= bar.a 14)) (assert (= a 1)) (assert (= b [])) ;; method syntax not affected