Last active

core.match + JAR troubles

  • Download Gist
1 2 3 4 5
(defproject match-jar "1.0.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.3.0"]
[org.clojure/core.match "0.2.0-alpha9"]]
:main core)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
(ns core
(:use [clojure.core.match :only [match]])
(defn m1 [x]
(match [x]
[{:type "A"}] "A"
[{:type "B"}] "B"
:else "no matches = ("))
(defn m2 [x]
;;manually macroexpanded version of form in m1.
(try (clojure.core/cond (clojure.core/or (clojure.core/instance? clojure.lang.ILookup x) (clojure.core/satisfies? clojure.core.match/IMatchLookup x)) (try (clojure.core/let [x_type__2413 (clojure.core.match/val-at* x :type :clojure.core.match/not-found)] (clojure.core/cond (clojure.core/= x_type__2413 "A") "A" (clojure.core/= x_type__2413 "B") "B" :else (throw clojure.core.match/backtrack))) (catch java.lang.Exception e__594__auto__ (if (clojure.core/identical? e__594__auto__ clojure.core.match/backtrack) (do (throw clojure.core.match/backtrack)) (throw e__594__auto__)))) :else (throw clojure.core.match/backtrack)) (catch java.lang.Exception e__594__auto__ (if (clojure.core/identical? e__594__auto__ clojure.core.match/backtrack) (do (clojure.core/let [] "no matches = (")) (throw e__594__auto__)))))
(defn -main [& args]
(println (m1 {:type "A"}))
(println (m1 {:type "B"}))
(println (m1 {:type "none"}))
(print "\n")
(println (m2 {:type "A"}))
(println (m2 {:type "B"}))
(println (m2 {:type "none"})))

So here's the story:

Running lein uberjar on source containing the offending function, geo->svg, results in a non-working application---the match always drops to the :else clause.
However, if match is manually macroexpanded in the repl and the results pasted in, then the JAR works just fine.

Updated to minimal example. Output:

kevin@sigma:~/gist-35fa11df$ java -jar match-jar-1.0.0-SNAPSHOT-standalone.jar 
no matches = (
no matches = (

no matches = (

This is with

Leiningen 1.7.0 on Java 1.7.0_03 Java HotSpot(TM) 64-Bit Server VM


cake 0.6.3

Thanks for taking the time to put this minimal example together, I'm finally looking into the AOT issues and this is super helpful.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.