@swannodette Considering a potential enhancement. Could use feedback. Low priority IMHO.
A user could define functions in the REPL that call into functions that are defined in source and then call those REPL-defined functions. If an exception occurs, JSC will emit only the function names in frames for REPL-defined functions.
The Clojure REPL supports this, using NO_SOURCE_FILE and line 1.
To support this would require minor changes to Ambly, and some changes to the underlying ClojureScript REPL as well.
Here is a concrete example showing that it almost works:
In actual source, I have:
(ns hello-ambly.core)
;; some lines have been deleted from here for brevity,
;; so stack line numbers below are off
(defn test-exception-two []
(ffirst 1))
(defn test-exception-one []
(test-exception-two))
wrap_one should be resolved to cljs.user/wrap-one
2, NO_SOURCE_FILE needs a little special handling to prevent code assuming it is a file in the :output-dir: out/NO_SOURCE_FILE.
I did the above by changing Ambly's parser a little to emit:
(defn stack-line->canonical-frame
"Parses a stack line into a frame representation, returning nil
if parse failed."
[stack-line opts]
(let [[function file line column]
(rest (re-matches #"(.*)@file://(.*):([0-9]+):([0-9]+)"
stack-line))]
(if-not (#{"" "global code"} stack-line)
{:file (if file
(string/replace
(.getCanonicalFile (io/file file))
(str (System/getProperty "user.dir") File/separator
(util/output-directory opts) File/separator)
"")
"NO_SOURCE_FILE")
:function (or function (string/trim stack-line))
:line (if line (Long/parseLong line) 1)
:column (if column (Long/parseLong column) 1)})))
This is a fairly lengthy description and probably needs some hammock time on whether to even pursue it, so I figured I'd drop it in an enhancement ticket here.
@swannodette Considering a potential enhancement. Could use feedback. Low priority IMHO.
A user could define functions in the REPL that call into functions that are defined in source and then call those REPL-defined functions. If an exception occurs, JSC will emit only the function names in frames for REPL-defined functions.
The Clojure REPL supports this, using
NO_SOURCE_FILE
and line 1.To support this would require minor changes to Ambly, and some changes to the underlying ClojureScript REPL as well.
Here is a concrete example showing that it almost works:
In actual source, I have:
And in the Ambly REPL:
Here is it nearly working:
The two things wrong:
wrap_one
should be resolved tocljs.user/wrap-one
2,NO_SOURCE_FILE
needs a little special handling to prevent code assuming it is a file in the:output-dir
:out/NO_SOURCE_FILE
.I did the above by changing Ambly's parser a little to emit:
This is a fairly lengthy description and probably needs some hammock time on whether to even pursue it, so I figured I'd drop it in an enhancement ticket here.