From 838cb04255b96420d6c3907ac89e63ab224d3cee Mon Sep 17 00:00:00 2001 From: Ryan Smith Date: Mon, 19 Jul 2021 11:20:50 -0700 Subject: [PATCH] Force bindings inside `let-flow` to be unique Without this, the following code can randomly pick "cat" or "dog" (though "dog" is far more common, making this bug hard to detect or reproduce). ```clj @(let-flow [a "cat" a "dog"] a) ``` Note: There's a likelyhood that users updating to this code will need to update their code base due to it failing to compile. I (Ryan Smith) find this acceptable as the code is already broken, even if the user hasn't realized it yet. --- src/manifold/deferred.clj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/manifold/deferred.clj b/src/manifold/deferred.clj index 80f87f00..7c4a31ac 100644 --- a/src/manifold/deferred.clj +++ b/src/manifold/deferred.clj @@ -1290,6 +1290,7 @@ (let [[_ bindings & body] (walk/macroexpand-all `(let ~bindings ~@body)) locals (keys (compiler/locals)) vars (->> bindings (partition 2) (map first)) + _ (assert (apply distinct? vars) "Let binding vars must be unique.") marker (gensym) vars' (->> vars (concat locals) (map #(vary-meta % assoc marker true))) gensyms (repeatedly (count vars') gensym)