Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown during phase :analyze of linting #60

Closed
xpe opened this issue Mar 21, 2014 · 7 comments
Closed

Exception thrown during phase :analyze of linting #60

xpe opened this issue Mar 21, 2014 · 7 comments
Assignees

Comments

@xpe
Copy link

xpe commented Mar 21, 2014

Running Eastwood on this open source Clojure project with considerable Java interop gives many exceptions (of which I've pasted the first):

$ lein eastwood
== Eastwood 0.1.1 Clojure 1.6.0-RC1 JVM 1.7.0_45
== Linting kria.conversions ==
== Linting kria.pb.pair ==
Exception thrown during phase :analyze of linting namespace kria.pb.pair
A function, macro, protocol method, var, etc. named byte-string<-utf8-string has been used here:
{:line 21, :column 19, :end-line 21, :end-column 43}
Wherever it is defined, or where it is called, it has a type of class clojure.lang.AFunction
dbgx tag=class clojure.lang.AFunction (class tag)=class java.lang.Class (str tag)='class clojure.lang.AFunction' boolean?=false long?=false

The following form was being processed during the exception:
(defn
 Pair->pb
 [r]
 (let
  [b (RiakPB$RpbPair/newBuilder)]
  (let [x (:key r)] (.setKey b (byte-string<-utf8-string x)))
  (if-let [x (:value r)] (.setValue b (byte-string<-utf8-string x)))
  (.build b)))

Shown again with metadata for debugging:
(^{:line 17, :column 2, :end-line 17, :end-column 6} defn
 ^{:tag ^{:line 17, :column 8, :end-line 17, :end-column 22} RiakPB$RpbPair, :line 17, :column 23, :end-line 18, :end-column 0} Pair->pb
 [^{:line 18, :column 4, :end-line 18, :end-column 5} r]
 (^{:line 19, :column 4, :end-line 19, :end-column 7} let
  [^{:line 19, :column 9, :end-line 19, :end-column 10} b
   (^{:line 19, :column 12, :end-line 19, :end-column 37} RiakPB$RpbPair/newBuilder)]
  (^{:line 20, :column 6, :end-line 20, :end-column 9} let
   [^{:line 20, :column 11, :end-line 20, :end-column 12} x
    (:key ^{:line 20, :column 19, :end-line 20, :end-column 20} r)]
   (^{:line 21, :column 8, :end-line 21, :end-column 15} .setKey
    ^{:line 21, :column 16, :end-line 21, :end-column 17} b
    (^{:line 21, :column 19, :end-line 21, :end-column 43} byte-string<-utf8-string
     ^{:line 21, :column 44, :end-line 21, :end-column 45} x)))
  (^{:line 22, :column 6, :end-line 22, :end-column 12} if-let
   [^{:line 22, :column 14, :end-line 22, :end-column 15} x
    (:value ^{:line 22, :column 24, :end-line 22, :end-column 25} r)]
   (^{:line 23, :column 8, :end-line 23, :end-column 17} .setValue
    ^{:line 23, :column 18, :end-line 23, :end-column 19} b
    (^{:line 23, :column 21, :end-line 23, :end-column 45} byte-string<-utf8-string
     ^{:line 23, :column 46, :end-line 23, :end-column 47} x)))
  (^{:line 24, :column 6, :end-line 24, :end-column 12} .build
   ^{:line 24, :column 13, :end-line 24, :end-column 14} b)))
@Bronsa
Copy link
Collaborator

Bronsa commented Mar 22, 2014

I've pushed a fix for this in a branch af34407

Before merging, @jafingerhut can you take a look at this?
That commit removes the special evaluation semantics for ns forms that AFAIK are no longer needed and removes the loaded-namespaces mechanism that should not be needed either since we now use tools.namespace to analyze the namespaces in the correct order.

@jafingerhut
Copy link
Collaborator

I tried pulling the latest version of project kria from Github, and unless I'm doing something wrong, it fails to compile with 'lein check', throwing an exception, and fails 'lein test' with the same exception, starting out as shown below. I am using Java 1.7.0_51 on Mac OS X 10.8.5, in case it makes any difference. Are you able to compile the project as it is checked in?

Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.main.(main.java:20)
Caused by: java.lang.ClassNotFoundException: com.basho.riak.protobuf.RiakPB$RpbErrorResp, compiling:(kria/pb/error.clj:1:1)
at clojure.lang.Compiler.load(Compiler.java:7142)
at clojure.lang.RT.loadResourceScript(RT.java:370)

@Bronsa
Copy link
Collaborator

Bronsa commented Mar 22, 2014

The readme tells you how to fix that: lein with-profile base javac, to compile the required java classes.

Took me a few minutes for me too to find it in there

@jafingerhut
Copy link
Collaborator

Thanks for the step I was missing, and the proposed fix. It definitely helps for kria. It also has the undesirable effect of causing :unlimited-use warnings to be reported inside namespace 'user' instead of the actual namespace that the 'ns' form is defining, but I can look into perhaps correcting that. Let me run it on the whole crucible set of projects and see if it causes any other changes in behavior.

@jafingerhut jafingerhut self-assigned this Mar 24, 2014
@jafingerhut
Copy link
Collaborator

I made a small additional change on top of Bronsa's. His fixes the problem reported: af34407

Mine just preserves the existing behavior in a few more cases by finishing the job he did most of: fcd64dd

It isn't part of a release yet, but hopefully will be within a week or two. Thanks for reporting the issue.

@jafingerhut
Copy link
Collaborator

I have also added kria to the list of projects that Eastwood is regularly tested against, since it exhibited this issue with Eastwood that none of the other projects did.

@xpe
Copy link
Author

xpe commented Mar 26, 2014

@jafingerhut @Bronsa Thanks for fixing this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants