From abae3d61be5a922d19766e3e431662d9ee2675c4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 19 Aug 2024 20:31:27 +0200 Subject: [PATCH] Don't use use polimorphic coersion on macro return values --- src/promesa/core.cljc | 8 ++++---- src/promesa/impl.cljc | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/promesa/core.cljc b/src/promesa/core.cljc index a726cf0..73eef56 100644 --- a/src/promesa/core.cljc +++ b/src/promesa/core.cljc @@ -564,7 +564,7 @@ expression." [& exprs] `(pt/-mcat - (pt/-promise nil) + (impl/resolved nil) (fn [_#] (promesa.core/do* ~@exprs)))) @@ -580,7 +580,7 @@ (assert (even? (count bindings)) (str "Uneven binding vector: " bindings)) (c/->> (reverse (partition 2 bindings)) (reduce (fn [acc [l r]] - `(pt/-mcat (pt/-promise ~r) (fn [~l] ~acc))) + `(pt/-mcat (impl/coerce ~r) (fn [~l] ~acc))) `(do* ~@body)))) (defmacro let @@ -589,7 +589,7 @@ [bindings & body] (if (seq bindings) `(pt/-mcat - (pt/-promise nil) + (impl/resolved nil) (fn [_#] (promesa.core/let* ~bindings ~@body))) `(promesa.core/do ~@body))) @@ -599,7 +599,7 @@ [bindings & body] (assert (even? (count bindings)) (str "Uneven binding vector: " bindings)) `(pt/-mcat - (pt/-promise nil) + (impl/resolved nil) (fn [_#] ~(c/let [bindings (partition 2 bindings)] `(c/-> (all ~(mapv second bindings)) diff --git a/src/promesa/impl.cljc b/src/promesa/impl.cljc index 56a7af6..6d1154e 100644 --- a/src/promesa/impl.cljc +++ b/src/promesa/impl.cljc @@ -54,11 +54,11 @@ (.completeExceptionally ^CompletableFuture p v) p))) -#?(:cljs - (defn coerce - "Coerce a thenable to built-in promise impl type." - [v] - (impl/coerce v))) +(defn coerce + [v] + (if (promise? v) + v + (resolved v))) (defn all [promises]