cloverage / cloverage

Clojure test coverage tool
Eclipse Public License 2.0
503 stars 99 forks source link

Using lamina.core/channel* results in an exception #53

Open jlambrecht opened 10 years ago

jlambrecht commented 10 years ago

Here is a minimal reproduction:

(ns test.core
  (:require [lamina.core :refer [channel*]]))

(defn get-channel
  []
  (channel*))

Running lein cloverage results in:

Exception in thread "main" java.lang.Exception: Couldn't eval form (cloverage.instrument/wrapm cloverage.coverage/track-coverage 4 ^{:file test/core.clj", :line 4, :column 1} (defn get-channel [] ^{:line 6, :column 3} (channel*)))

...

Caused by: java.lang.IllegalArgumentException: No matching ctor found for class clojure.lang.AFunction$1
    at clojure.lang.Reflector.invokeConstructor(Reflector.java:163)
    at clojure.lang.LispReader$EvalReader.invoke(LispReader.java:1043)
    at clojure.lang.LispReader$DispatchReader.invoke(LispReader.java:616)
    at clojure.lang.LispReader.read(LispReader.java:183)
    at clojure.lang.RT.readString(RT.java:1737)
    at test.core$get_channel.<clinit>(test/core.clj:1)
    ... 34 more

The project.clj is:

(defproject test "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [riddley "0.1.6"]
                 [lamina "0.5.2"]]

  :plugins [[lein-cloverage "1.0.2"]])

Notice that I have [riddley "0.1.6"] in :dependencies. This is because of the workaround identified in issue #47. If the riddley dependency is removed the exception is:

Exception in thread "main" java.lang.Exception: Couldn't eval form (cloverage.instrument/wrapm cloverage.coverage/track-coverage 1 ^{:file "test/core.clj", :line 1, :column 1} (ns test.core ^{:line 2, :column 3} (:require [lamina.core :refer [channel*]])))

...

Caused by: java.lang.RuntimeException: Unable to resolve symbol: o in this context
    at clojure.lang.Util.runtimeException(Util.java:221)
    at clojure.lang.Compiler.resolveIn(Compiler.java:6940)
    at clojure.lang.Compiler.resolve(Compiler.java:6884)
    at clojure.lang.Compiler.analyzeSymbol(Compiler.java:6845)
    at clojure.lang.Compiler.analyze(Compiler.java:6427)
    ... 179 more
devn commented 9 years ago

I get something very similar to this with a project that isn't using lamina. Not sure of the reason.

lvh commented 8 years ago

@devn You wouldn't happen to be able to produce a minimal case? @jlambrecht Did you ever figure out what's going on here?

JacekLach commented 8 years ago

This is http://dev.clojure.org/jira/browse/CLJ-1206 - there is a function object somewhere in the evaled code (rather than the 'code for the function'). It seems that either things are getting evalled twice somewhere, or channel* internally expands into a function object rather than code.

I can't seem to load lamina using lein-try, so I can't really say what this macroexpands to. I suggest running this through (wrap #'nop 0 '(channel*)) with debug set on, and inspecting the macroexpansion step by step. Before it crashes it should print out the form it's trying to eval, which should have some weirdness inside (I expect a function object).

jlambrecht commented 8 years ago

@lvh no, I never did get to the bottom of this.

rbuchmann commented 7 years ago

@JacekLach Thanks for the hint, helped me fix a similar problem to #164 !