Multiple errors on multiple functions (invalid arity)
Closed this issue · 5 comments
Sorry, I don't even know how make a meaningful title to help you but anyway...
I'm integrating Sayid on Atom using my plugin "clojure-plus", but I'm having a lot of errors on a lot of functions. For instance, in "inner trace":
(sayid/ws-add-inner-trace-fn! f) ; This "f" is a full qualified symbol
=> NullPointerException
(sayid/ws-inner-trace-apply 'some/function [10 20])
=> ArityException Wrong number of args (2) passed to: inner-trace2/inner-tracer clojure.lang.AFn.throwArity (AFn.java:429)
(sayid/ws-inner-trace-apply-print 'some/function [10 20])
=> ArityException Wrong number of args (2) passed to: inner-trace2/inner-tracer clojure.lang.AFn.throwArity (AFn.java:429)
(sayid/ws-replay-id! :30174)
ArityException Wrong number of args (1) passed to: core/ws-query clojure.lang.AFn.throwArity (AFn.java:429)
(sayid/ws-query-inner-trace-replay [:id id])
NullPointerException clojure.lang.Compiler.maybeResolveIn (Compiler.java:7174)
What's going on? Are these functions really not meant to be used? If so, how can I do an inner trace?
Another (STRANGE!) example:
(defn test4 [x y]
(let [a 10
b (delay (+ x y))]
(when-let [c @b]
(inc c))))
(test4 10 20) ; => 31
(sayid/ws-add-inner-trace-fn! test4)
(test4 10 20) ; => nil. WAT?
(sayid/ws-print)
; v clj.test-ns/test4 :50317
; | x => 10
; | y => 20
; | returns => nil
; |v (let* [a 10 b (new clojure.lang.Delay (fn* [] (+ x y)))] (let* [temp__4657__auto__ b] (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c)))))) clj.test-ns/test4 :50318
; || a <= 10 <= 10
; || b <= #object[clojure.lang.Delay 0x2bed321b {:status :pending, :val nil}] <= (delay (+ x y))
; || returns => nil
; ||v (when-let [c b] (inc c)) => (let* [temp__4657__auto__ b] (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c))))) clj.test-ns/test4 :50319
; ||| returns => nil
; |||v (clojure.core/when temp__4657__auto__ (clojure.core/let [c temp__4657__auto__] (inc c))) => (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c)))) clj.test-ns/test4 :50320
; |||| #object[clojure.lang.Delay 0x2bed321b {:status :pending, :val nil}]
; |||| nil
; |||| returns => nil
; ||||v (clojure.core/let [c temp__4657__auto__] (inc c)) => (let* [c temp__4657__auto__] (inc c)) clj.test-ns/test4 :50321
; ||||| returns => nil
; |||||v ! (inc c) clj.test-ns/test4 :50322
; |||||| #object[clojure.lang.Delay 0x2bed321b {:status :pending, :val nil}]
; |||||| returned => nil
; |||||| THROW => {:cause "clojure.lang.Delay cannot be cast to java.lang.Number"}
; |||||| :via [{:type java.lang.ClassCastException}]
; |||||| :message "clojure.lang.Delay cannot be cast to java.lang.Number"
; |||||| :at {:class-name "clojure.lang.Numbers"}
; |||||| :file-name "Numbers.java"
; |||||| :method-name "inc"
; |||||| :line-number 112
; |||||| :trace [{:class-name "clojure.lang.Numbers"}]
; |||||| :file-name "Numbers.java"
; |||||| :method-name "inc"
; |||||| :line-number 112
; |||||| {:class-name "clojure.core$inc"}
; |||||| :file-name "core.clj"
; |||||| :method-name "invokeStatic"
; |||||| :line-number 908
; |||||| {:class-name "clojure.core$inc"}
; |||||| :file-name "core.clj"
; |||||| :method-name "invoke"
; |||||| :line-number 903
; |||||| {:class-name "clojure.lang.AFn"}
; |||||| :file-name "AFn.java"
; |||||| ...
; ||||||
; |||||| ...
; ||||||
; |||||^
; ||||| (clojure.core/let [c temp__4657__auto__] (inc c)) => (let* [c temp__4657__auto__] (inc c)) clj.test-ns/test4 :50321
; ||||| returned => nil
; ||||^
; |||| (clojure.core/when temp__4657__auto__ (clojure.core/let [c temp__4657__auto__] (inc c))) => (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c)))) clj.test-ns/test4 :50320
; |||| #object[clojure.lang.Delay 0x2bed321b {:status :pending, :val nil}]
; |||| nil
; |||| returned => nil
; |||^
; ||| (when-let [c b] (inc c)) => (let* [temp__4657__auto__ b] (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c))))) clj.test-ns/test4 :50319
; ||| returned => nil
; ||^
; || (let* [a 10 b (new clojure.lang.Delay (fn* [] (+ x y)))] (let* [temp__4657__auto__ b] (if temp__4657__auto__ (do (let* [c temp__4657__auto__] (inc c)))))) clj.test-ns/test4 :50318
; || a <= 10 <= 10
; || b <= #object[clojure.lang.Delay 0x2bed321b {:status :pending, :val nil}] <= (delay (+ x y))
; || returned => nil
; |^
; | clj.test-ns/test4 :50317
; | x => 10
; | y => 20
; | returned => nil
; ^
@mauricioszabo Thanks for letting me know about all of this mess. I'm going to look at each of your examples tonight and see if I can come with any useful answers, but either way, inner trace is known (by me at least) to be buggy and I intend to do an overhaul asap.
I made a quick, but unsuccessful, attempt to reproduce a couple of your issues. My code is below.
What version of clojure are you using?
For your test4
example, you can see in the sayid output you posted that the deref
is missing, which is weird. I don't know why it would miss only that.
; ||v (when-let [c b] (inc c)) => ...
The other functions you tried just seem to be broken. I haven't used them in a while. Sorry for the confusion. I'll add those to my todo list.
Here's my code and results. Am I doing exactly what you are?
(ns user
(:require [com.billpiel.sayid.core :as sd]))
(sd/ws-clear-log!)
(defn f [a b] (+ a b))
(sd/ws-add-inner-trace-fn! f)
(f 1 2) ; => 3
(sd/ws-print)
(sd/ws-clear-log!)
(defn f2
[x y]
(let [a 10
b (delay (+ x y))]
(when-let [c @b]
(inc c))))
(sd/ws-add-inner-trace-fn! f2)
(f2 10 20) ; => 31
(sd/ws-print)
v user/f :14422
| a => 1
| b => 2
| returns => 3
|v (+ a b) user/f :14423
|| 1
|| 2
|| returned => 3
|^
| user/f :14422
| a => 1
| b => 2
| returned => 3
^
v user/f2 :14448
| x => 10
| y => 20
| returns => 31
|v (let* [a 10 b (new clojure.lang.Delay (fn* [] (+ x y)))] (let* [temp__4425__auto__ (clojure.core/deref b)] (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c)))))) user/f2 :14449
|| a <= 10 <= 10
|| b <= #delay[{:status :ready, :val 30} 0x3ed77fb3] <= (delay (+ x y))
|| returns => 31
||v (when-let [c (clojure.core/deref b)] (inc c)) => (let* [temp__4425__auto__ (clojure.core/deref b)] (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c))))) user/f2 :14450
||| returns => 31
|||v (clojure.core/deref b) user/f2 :14451
|||| #delay[{:status :ready, :val 30} 0x3ed77fb3]
|||| returned => 30
|||^
|||v (clojure.core/when temp__4425__auto__ (clojure.core/let [c temp__4425__auto__] (inc c))) => (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c)))) user/f2 :14452
|||| 30
|||| 31
|||| returns => 31
||||v (clojure.core/let [c temp__4425__auto__] (inc c)) => (let* [c temp__4425__auto__] (inc c)) user/f2 :14453
||||| returns => 31
|||||v (inc c) user/f2 :14454
|||||| 30
|||||| returned => 31
|||||^
||||| (clojure.core/let [c temp__4425__auto__] (inc c)) => (let* [c temp__4425__auto__] (inc c)) user/f2 :14453
||||| returned => 31
||||^
|||| (clojure.core/when temp__4425__auto__ (clojure.core/let [c temp__4425__auto__] (inc c))) => (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c)))) user/f2 :14452
|||| 30
|||| 31
|||| returned => 31
|||^
||| (when-let [c (clojure.core/deref b)] (inc c)) => (let* [temp__4425__auto__ (clojure.core/deref b)] (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c))))) user/f2 :14450
||| returned => 31
||^
|| (let* [a 10 b (new clojure.lang.Delay (fn* [] (+ x y)))] (let* [temp__4425__auto__ (clojure.core/deref b)] (if temp__4425__auto__ (do (let* [c temp__4425__auto__] (inc c)))))) user/f2 :14449
|| a <= 10 <= 10
|| b <= #delay[{:status :ready, :val 30} 0x3ed77fb3] <= (delay (+ x y))
|| returned => 31
|^
| user/f2 :14448
| x => 10
| y => 20
| returned => 31
^
I'm using Clojure 1.8.
I tried your example, and on (sayid/ws-add-inner-trace-fn! f2)
, I've got this:
Exception Expected a defn form, but got this (+ c ... com.billpiel.sayid.inner-trace2/get-fn (inner_trace2.clj:598)
Then, I've restarted my REPL and got the following error:
ExceptionInfo EOF clojure.core/ex-info (core.clj:4617)
clojure.lang.ExceptionInfo: EOF {:type :reader-exception, :line 18, :column 6, :file "/tmp/form-init2426333707173738017.clj"}
Then, I though it would be better to save a file before trying to trace anything, and then things worked. Maybe better error messages?
Well, can you please keep this issue open for, let's say, 3 or 4 days? If I don't find a way to reproduce it (even with these codes on an updated file) I'll post here, otherwise we can close it :)
Sounds good. thanks