[CLJS]: Usage of core.match within core.async/go block causes compilation to fail when match cases exceed a certain count

Description

This works in Clojure but fails in ClojureScript.
Reproduced in this repo: https://github.com/den1k/core-match-test

Failure case:

(ns core-match-test.core
(:require-macros [cljs.core.async.macros :refer [go]]
[cljs.core.match :refer [match]]))

;; The first two cases below will compile while the third will not
;; To reproduce run `lein cljsbuild auto
;; after successful compilation comment in last test case and save
;; note console output

;; This will compile
(defn compile-test [vec-to-match]
(match [vec-to-match]
[[:test :1]] (prn vec-to-match)
[[:test :2]] (prn vec-to-match)
[[:test :3]] (prn vec-to-match)
[[:test :4]] (prn vec-to-match)
[[:test :5]] (prn vec-to-match)
[[:test :6]] (prn vec-to-match)
[[:test :7]] (prn vec-to-match)
[[:test :8 arg]] (prn vec-to-match arg)
[[:test :9]] (prn vec-to-match)))

;; This will also compile
(defn compile-test2 [vec-to-match]
(go ;; <= added `go`
(match [vec-to-match]
[[:test :1]] (prn vec-to-match)
[[:test :2]] (prn vec-to-match)
[[:test :3]] (prn vec-to-match)
[[:test :4]] (prn vec-to-match)
[[:test :5]] (prn vec-to-match)
;[[:test :6]] (prn vec-to-match)
[[:test :7]] (prn vec-to-match)
[[:test :8 arg]] (prn vec-to-match arg)
[[:test :9]] (prn vec-to-match))))

;; This will not compile
#_(defn compile-test3 [vec-to-match]
(go
(match [vec-to-match]
[[:test :1]] (prn vec-to-match)
[[:test :2]] (prn vec-to-match)
[[:test :3]] (prn vec-to-match)
[[:test :4]] (prn vec-to-match)
[[:test :5]] (prn vec-to-match)
[[:test :6]] (prn vec-to-match) ;; <= commented in line
[[:test :7]] (prn vec-to-match)
[[:test :8 arg]] (prn vec-to-match arg)
[[:test :9]] (prn vec-to-match)
)))

Environment

Mac OS X Mavericks, JDK 1.8

Activity

Show:
import
August 8, 2015, 4:28 PM

Comment made by: kalavox@gmail.com

I could not reproduce this on a different machine, running JDK 1.7. I assume this is a caching issue in the compiler? I will investigate further, this can be closed.

import
August 8, 2015, 4:38 PM

Comment made by: kalavox@gmail.com

Exception:

Compiling "resources/public/js/compiled/core_match_test.js" failed.
java.lang.StackOverflowError:
AFn.java:148 clojure.lang.AFn.applyToHelper
RestFn.java:132 clojure.lang.RestFn.applyTo
core.clj:630 clojure.core/apply
core.clj:3605 clojure.core/print
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:630 clojure.core/apply
core.clj:4581 clojure.core/print-str
RestFn.java:408 clojure.lang.RestFn.invoke
compiler.cljc:175 cljs.compiler$emits.doInvoke
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:630 clojure.core/apply
compiler.cljc:173 cljs.compiler$emits.doInvoke
RestFn.java:408 clojure.lang.RestFn.invoke
compiler.cljc:1020 cljs.compiler$eval3142$fn__3144.invoke
MultiFn.java:229 clojure.lang.MultiFn.invoke
compiler.cljc:166 cljs.compiler$emit.invoke
compiler.cljc:172 cljs.compiler$emits.doInvoke
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:630 clojure.core/apply
compiler.cljc:183 cljs.compiler$emitln.doInvoke
RestFn.java:408 clojure.lang.RestFn.invoke
compiler.cljc:746 cljs.compiler$eval2946$fn__2948.invoke
MultiFn.java:229 clojure.lang.MultiFn.invoke
compiler.cljc:166 cljs.compiler$emit.invoke
compiler.cljc:172 cljs.compiler$emits.doInvoke
RestFn.java:408 clojure.lang.RestFn.invoke
compiler.cljc:786 cljs.compiler$emit_let$fn__2971.invoke
compiler.cljc:771 cljs.compiler$emit_let.invoke
compiler.cljc:793 cljs.compiler$eval2982$fn__2983.invoke
MultiFn.java:229 clojure.lang.MultiFn.invoke
compiler.cljc:166 cljs.compiler$emit.invoke
compiler.cljc:172 cljs.compiler$emits.doInvoke
RestFn.java:137 clojure.lang.RestFn.applyTo
core.clj:630 clojure.core/apply

David Nolen
September 18, 2015, 6:00 PM

This is a core.async issue not a core.match one. Even so combining both macros will never be recommended. Move the match outside your go block.

Assignee

David Nolen

Reporter

import

Labels

Approval

None

Patch

None

Priority

Major
Configure