Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MATCH-67: CLJS support regression

syntax for try/catch in ClojureScript chagned to match clojure. We can
no longer catch 0 since `0 instanceof Number` is false in
JavaScript. We now catch a preallocated Error just like we do in
Clojure proper. Users must now include `clojure.core.match` namespace as
well as requiring the macros files.

Started adding tests so we can notice ClojureScript regression sooner.
  • Loading branch information...
commit 3bab92b6620dccdcb9e55941af4599e3adf78a6e 1 parent 68709c4
David Nolen authored February 15, 2013
6  project.clj
@@ -11,19 +11,19 @@
11 11
 
12 12
   :dependencies [[org.clojure/clojure "1.4.0"]
13 13
                  [org.clojure/clojurescript "0.0-1576"]]
14  
-  :dev-dependencies [[nrepl "0.2.1"]]
  14
+  :dev-dependencies [[org.clojure/tools.nrepl "0.2.1"]]
15 15
   :plugins [[lein-cljsbuild "0.3.0"]]
16 16
 
17 17
   :cljsbuild
18 18
   {:builds
19 19
    [{:id "test"
20 20
      :source-paths ["src/test/cljs"]
21  
-     :compiler {:output-js "test.js"
  21
+     :compiler {:output-to "test.js"
22 22
                 :pretty-print true
23 23
                 :static-fns true
24 24
                 :optimizations :simple}}
25 25
     {:id "test-adv"
26 26
      :source-paths ["src/test/cljs"]
27  
-     :compiler {:output-js "test-adv.js"
  27
+     :compiler {:output-to "test-adv.js"
28 28
                 :pretty-print true
29 29
                 :optimizations :advanced}}]})
6  src/main/clojure/clojure/core/match.clj
@@ -79,7 +79,7 @@
79 79
 
80 80
 (defn backtrack-expr []
81 81
   (if *clojurescript*
82  
-    `(throw 0)
  82
+    `(throw clojure.core.match/backtrack)
83 83
     `(throw clojure.core.match/backtrack)))
84 84
 
85 85
 (defn warn [msg]
@@ -439,8 +439,8 @@
439 439
 
440 440
 (defn catch-error [& body]
441 441
   (if *clojurescript*
442  
-    `(catch e#
443  
-       (if (identical? e# 0)
  442
+    `(catch js/Error e#
  443
+       (if (identical? e# clojure.core.match/backtrack)
444 444
          (do
445 445
            ~@body)
446 446
          (throw e#)))
3  src/main/clojure/clojure/core/match.cljs
... ...
@@ -0,0 +1,3 @@
  1
+(ns clojure.core.match)
  2
+
  3
+(def backtrack (js/Error.))
3  src/test/cljs/clojure/core/match/js/tests.cljs
... ...
@@ -1,5 +1,6 @@
1 1
 (ns clojure.core.match.js.tests
2  
-  (:use-macros [clojure.core.match.js :only [match]]))
  2
+  (:use-macros [clojure.core.match.js :only [match]])
  3
+  (:require [clojure.core.match]))
3 4
 
4 5
 (defn js-print [& args]
5 6
   (if (js* "typeof console != 'undefined'")

0 notes on commit 3bab92b

Please sign in to comment.
Something went wrong with that request. Please try again.