Created
June 24, 2013 15:01
-
-
Save thheller/5850693 to your computer and use it in GitHub Desktop.
core.match bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use '[clojure.core.match :only (match)]) | |
(use clojure.pprint) | |
(def form | |
'(match [(do-something)] | |
[[:ok value]] value | |
[[:error :not-found]] (do-something-else))) | |
(pprint (macroexpand-1 form)) | |
;; PRODUCES | |
(clojure.core/let | |
[ocr-9301 (do-something)] | |
(try | |
(clojure.core/cond | |
(clojure.core/and | |
(clojure.core/vector? ocr-9301) | |
(clojure.core/== (clojure.core/count ocr-9301) 2)) | |
(try | |
(clojure.core/let | |
[ocr-9301_0__9302 (clojure.core/nth ocr-9301 0)] | |
(clojure.core/cond | |
(clojure.core/= ocr-9301_0__9302 :ok) | |
(clojure.core/let [value (clojure.core/nth ocr-9301 1)] value) | |
(clojure.core/= ocr-9301_0__9302 :error) | |
(try | |
(clojure.core/let | |
[ocr-9301_1__9303 (clojure.core/nth ocr-9301 1)] | |
(clojure.core/cond | |
(clojure.core/= ocr-9301_1__9303 :not-found) | |
(do-something-else) | |
:else | |
(throw clojure.core.match/backtrack))) | |
(catch | |
Exception | |
e__8599__auto__ | |
(if | |
(clojure.core/identical? | |
e__8599__auto__ | |
clojure.core.match/backtrack) | |
(do (throw clojure.core.match/backtrack)) | |
(throw e__8599__auto__)))) | |
:else | |
(throw clojure.core.match/backtrack))) | |
(catch | |
Exception | |
e__8599__auto__ | |
(if | |
(clojure.core/identical? | |
e__8599__auto__ | |
clojure.core.match/backtrack) | |
(do (throw clojure.core.match/backtrack)) | |
(throw e__8599__auto__)))) | |
:else | |
(throw clojure.core.match/backtrack)) | |
(catch | |
Exception | |
e__8599__auto__ | |
(if | |
(clojure.core/identical? | |
e__8599__auto__ | |
clojure.core.match/backtrack) | |
(do | |
(throw | |
(java.lang.IllegalArgumentException. | |
(clojure.core/str "No matching clause: " (do-something))))) | |
(throw e__8599__auto__))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment