Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed May 5, 2020
1 parent cc743d7 commit 438ec15
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/sci/impl/destructure.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@
:cljs (implements? INamed bb))
(with-meta (symbol nil (name bb)) (meta bb))
bb)
bk (if (symbol? bk) (list 'quote bk) bk)
;; if bk has metadata (:line, :column, etc)
;; then it's a binding that needs eval
bk (if-not (meta bk)
(list 'quote bk)
bk)
bv (if-let [default (get defaults local)]
(mark-eval-call (list get gmap bk default))
(mark-eval-call (list get gmap bk)))]
Expand Down
1 change: 1 addition & 0 deletions test/sci/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
(deftest destructure-test
(is (= 1 (eval* nil "(let [{:keys [a]} {:a 1}] a)")))
(is (= 1 (eval* nil "(let [{:keys [:a]} {:a 1}] a)")))
(is (= 42 (eval* nil "(let [k 'foo, a-map {k 42}, {foo-val k} a-map] foo-val)")))
(is (= 1 (eval* nil "((fn [{:keys [a]}] a) {:a 1})")))
(is (= 1 (eval* nil "((fn [{:keys [:a]}] a) {:a 1})")))
(is (= 1 (eval* nil "((fn [{:person/keys [id]}] id) {:person/id 1})")))
Expand Down

0 comments on commit 438ec15

Please sign in to comment.