technomancy / slamhound

Slamhound rips your namespace form apart and reconstructs it.
Other
473 stars 38 forks source link

Doesn't work properly in core.async projects #81

Open zilti opened 10 years ago

zilti commented 10 years ago

Slamhound fails to work properly in core.async projects, stating to

clojure.lang.ExceptionInfo: Could not resolve var: <! {:file "/tmp/form-init3522239263416655239.clj", :var <!}, compiling:(/tmp/form-init3522239263416655239.clj:1:130)

Same goes, by the way, for the lz4-compressor addon for nippy.

guns commented 10 years ago

Could you please provide an example namespace? I believe <! should be ignored once the surrounding go macro is resolved. Thank you!

EDIT: By ignored, I mean that that <! is not present in the macroexpansion of go

zilti commented 10 years ago

I made this, but it only got me a totally different error message:

(ns slamhoundtest.core
  (:require [clojure.core.async :refer [go chan >!] :as async]))

(defn something [x]
  (let [ch (chan)]
    (go (>! ch x))
    ch))
Failed to reconstruct: #<File src/slamhoundtest/core.clj>
java.lang.IllegalArgumentException: No implementation of method: :has? of protocol: #'clojure.core.cache/CacheProtocol found for class: clojure.core.memoize.PluggableMemoization, compiling:(/tmp/form-init5412601528044524872.clj:1:130)
guns commented 10 years ago

Hello,

This example ns works for me. However, that error is familiar: one of your dependencies is pulling in an old version of clojure.core.cache (or clojure.core.memoize; I don't recall precisely).

Googling that exception message should turn up workarounds by Ambrose Bonnaire-Sergeant and Andy Fingerhut.

As far as Slamhound is concerned, could you please test again with a clean :dependencies vector in both ~/.lein/profiles.clj and project.clj? (Aside from slamhound, of course).

Thank you!

zilti commented 10 years ago

All I get now is

Couldn't resolve go, got as far as {:refer {clojure.core.async.impl.channels #{chan}}, :old {:load nil, :exclude {}, :xr
efer #{}, :require #{}, :refer-all #{}, :verbose #{}, :rename {}, :alias {}, :reload #{}, :reload-all #{}, :gen-class ni
l, :import #{}, :refer {clojure.core.async #{chan go >!}}}, :meta nil, :name testslamhound.core}
guns commented 10 years ago

Could you post an example buffer please? I have not personally run into any problems with core.async

zilti commented 10 years ago

It's the exact buffer I posted in here.

guns commented 10 years ago

Then I can not reproduce, unfortunately. I am interested in uncovering the issue, so could you please post an example repository with project.clj + example source?

ktsujister commented 10 years ago

I also got the same issue.

project.clj

(defproject sh-issue "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"]
                 [org.clojure/core.async "0.1.338.0-5c5012-alpha"]])

core.clj

(ns sh-issue.core)

(defn something [x]
  (let [ch (chan)]
    (go (>! ch x))
        ch))

error in cider:

java.lang.IllegalArgumentException: No implementation of method: :has? of protocol: #'clojure.core.cache/CacheProtocol found for class: clojure.core.memoize.PluggableMemoization, compiling:(/tmp/form-init6791368952718665537.clj:1:34)

lein version: Leiningen 2.4.3 on Java 1.7.0_40 Java HotSpot(TM) 64-Bit Server VM

CIDER version: CIDER 0.7.0 (package: 20140805.516) (Java 1.7.0_40, Clojure 1.6.0, nREPL 0.2.3, cider-nrepl 0.7.0)

slamhound version: [slamhound "1.5.5"]

ktsujister commented 10 years ago

above project failed from command line too.

$ lein slamhound src/sh_issue/core.clj
Failed to reconstruct: #<File src/sh_issue/core.clj>
ava.lang.IllegalArgumentException: No implementation of method: :has? of protocol: #'clojure.core.cache/CacheProtocol found for class: clojure.core.memoize.PluggableMemoization, compiling:(/tmp/form-init1312218144590476856.clj:1:45)
ToBeReplaced commented 10 years ago

Confirming I see the same issue. Moreover, if you bump core.cache to 0.6.4, you get back to the Could not resolve var issue for >! and <!. I was unable to get slamhound to work with any version of core.async past 0.1.278.