From e1138747d9ed0f8be24fcd5e81417eeacab5cb08 Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Fri, 3 Jun 2016 16:25:27 -0400 Subject: [PATCH] fix #103 --- CHANGES.md | 3 ++- src/clj/com/rpl/specter.cljx | 4 ++-- test/com/rpl/specter/core_test.cljx | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c2d5e72..d2ca58b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,8 +4,9 @@ * Significant performance improvements for FIRST/LAST for vectors * Eliminated compiler warnings for ClojureScript version * Dropped support for Clojurescript below v1.7.10 -* Bug fix: `transformed` transform-fn no longer factors into `pred` when an anonymous function during inline factoring * Added :notpath metadata to signify pathedfn arguments that should be treated as regular arguments during inline factoring. If one of these arguments is not a static var reference or a non-collection value, the path will not factor. +* Bug fix: `transformed` transform-fn no longer factors into `pred` when an anonymous function during inline factoring +* Bug fix: Fixed nil->val to not navigate to the val on `false` ## 0.11.0 * New `path` macro does intelligent inline caching of the provided path. The path is factored into a static portion and into params which may change on each usage of the path (e.g. local parameters). The static part is factored and compiled on the first run-through, and then re-used for all subsequent invocations. As an example, `[ALL (keypath k)]` is factored into `[ALL keypath]`, which is compiled and cached, and `[k]`, which is provided on each execution. If it is not possible to precompile the path (e.g. [ALL some-local-variable]), nothing is cached and the path will be compiled on each run-through. diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index f178834..8d66c0f 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -416,9 +416,9 @@ nil->val [v] (select* [this structure next-fn] - (next-fn (if structure structure v))) + (next-fn (if (nil? structure) v structure))) (transform* [this structure next-fn] - (next-fn (if structure structure v)))) + (next-fn (if (nil? structure) v structure)))) (def NIL->SET (nil->val #{})) (def NIL->LIST (nil->val '())) diff --git a/test/com/rpl/specter/core_test.cljx b/test/com/rpl/specter/core_test.cljx index 1a23b59..0ce685f 100644 --- a/test/com/rpl/specter/core_test.cljx +++ b/test/com/rpl/specter/core_test.cljx @@ -1011,3 +1011,9 @@ (dotimes [i 10] (is (= [(inc i)] (select (s/transformed s/STAY #(+ % i)) 1))) )) + +;; test for issue #103 +(deftest nil->val-regression-test + (is (= false (transform (s/nil->val true) identity false))) + (is (= false (select-one! (s/nil->val true) false))) + ) \ No newline at end of file