SCI: use mutable arrays for bindings (#1177)

This commit is contained in:
Michiel Borkent 2022-02-14 11:52:32 +01:00 committed by GitHub
parent 9969b83341
commit b461925981
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 24 deletions

View file

@ -14,7 +14,7 @@
"depstar/src" "process/src" "depstar/src" "process/src"
"deps.clj/src" "deps.clj/resources" "deps.clj/src" "deps.clj/resources"
"resources" "sci/resources"], "resources" "sci/resources"],
:deps {org.clojure/clojure {:mvn/version "1.11.0-alpha4"}, :deps {org.clojure/clojure {:mvn/version "1.11.0-beta1"},
borkdude/sci {:local/root "sci"} borkdude/sci {:local/root "sci"}
babashka/babashka.curl {:local/root "babashka.curl"} babashka/babashka.curl {:local/root "babashka.curl"}
babashka/fs {:local/root "fs"} babashka/fs {:local/root "fs"}
@ -26,7 +26,7 @@
cheshire/cheshire {:mvn/version "5.10.2"} cheshire/cheshire {:mvn/version "5.10.2"}
org.clojure/data.xml {:mvn/version "0.2.0-alpha6"} org.clojure/data.xml {:mvn/version "0.2.0-alpha6"}
clj-commons/clj-yaml {:mvn/version "0.7.107"} clj-commons/clj-yaml {:mvn/version "0.7.107"}
com.cognitect/transit-clj {:mvn/version "1.0.324"} com.cognitect/transit-clj {:mvn/version "1.0.329"}
org.clojure/test.check {:mvn/version "1.1.1"} org.clojure/test.check {:mvn/version "1.1.1"}
nrepl/bencode {:mvn/version "1.1.0"} nrepl/bencode {:mvn/version "1.1.0"}
seancorfield/next.jdbc {:mvn/version "1.1.610"} seancorfield/next.jdbc {:mvn/version "1.1.610"}
@ -120,7 +120,9 @@
meta-merge/meta-merge {:mvn/version "1.0.0"} meta-merge/meta-merge {:mvn/version "1.0.0"}
com.exoscale/lingo {:mvn/version "1.0.0-alpha14"} com.exoscale/lingo {:mvn/version "1.0.0-alpha14"}
io.github.swirrl/dogstatsd {:mvn/version "0.1.39"} io.github.swirrl/dogstatsd {:mvn/version "0.1.39"}
org.clojure/algo.monads {:mvn/version "0.1.6"}} org.clojure/algo.monads {:mvn/version "0.1.6"}
io.lambdaforge/datalog-parser {:mvn/version "0.1.9"}
clj-stacktrace/clj-stacktrace {:mvn/version "0.2.8"}}
:classpath-overrides {org.clojure/clojure nil :classpath-overrides {org.clojure/clojure nil
org.clojure/spec.alpha nil}} org.clojure/spec.alpha nil}}
:clj-nvd :clj-nvd

2
sci

@ -1 +1 @@
Subproject commit 2f5d287d27b9ebed8b4c0a8c59939a4c9da1ec26 Subproject commit cbdf0ce72204535d73c5974784712c1f7dcaf883

View file

@ -139,10 +139,6 @@
(ruler "Context") (ruler "Context")
(println ec) (println ec)
(println)) (println))
(when-let [locals (and (:debug opts) (not-empty (:locals d)))]
(ruler "Locals")
(print-locals locals)
(println))
(when sci-error? (when sci-error?
(when-let (when-let
[st (let [st (with-out-str [st (let [st (with-out-str

View file

@ -208,9 +208,6 @@ Location: <expr>:1:12
1: (let [x 1] (/ x 0)) 1: (let [x 1] (/ x 0))
^--- Divide by zero ^--- Divide by zero
----- Locals -------------------------------------------------------------------
x: 1
----- Stack trace -------------------------------------------------------------- ----- Stack trace --------------------------------------------------------------
clojure.core// - <built-in> clojure.core// - <built-in>
user - <expr>:1:12 user - <expr>:1:12
@ -219,13 +216,13 @@ user - <expr>:1:12
clojure.lang.ExceptionInfo: Divide by zero clojure.lang.ExceptionInfo: Divide by zero
{:type :sci/error, :line 1, :column 12, :message \"Divide by zero\","))))) {:type :sci/error, :line 1, :column 12, :message \"Divide by zero\",")))))
(deftest macro-locals-print-test (deftest macro-test
(testing "exception during macro call includes &form and &env locals" (let [output (try (tu/bb nil "--debug" "(defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)")
(let [output (try (tu/bb nil "--debug" "(defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)") (is false)
(is false) (catch Exception e (ex-message e)))
(catch Exception e (ex-message e)))] output (tu/normalize output)]
(is (str/includes? (tu/normalize output) (is (str/includes? output
"----- Error -------------------------------------------------------------------- "----- Error --------------------------------------------------------------------
Type: java.lang.NullPointerException Type: java.lang.NullPointerException
Location: <expr>:1:19 Location: <expr>:1:19
Phase: macroexpand Phase: macroexpand
@ -234,11 +231,6 @@ Phase: macroexpand
1: (defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1) 1: (defmacro foo [x] (subs nil 1) `(do ~x ~x)) (foo 1)
^--- ^---
----- Locals -------------------------------------------------------------------
&form: (foo 1)
&env: {}
x: 1
----- Stack trace -------------------------------------------------------------- ----- Stack trace --------------------------------------------------------------
clojure.core/subs - <built-in> clojure.core/subs - <built-in>
user/foo - <expr>:1:19 user/foo - <expr>:1:19
@ -247,7 +239,7 @@ user - <expr>:1:45
----- Exception ---------------------------------------------------------------- ----- Exception ----------------------------------------------------------------
clojure.lang.ExceptionInfo: null clojure.lang.ExceptionInfo: null
{:type :sci/error, :line 1, :column 19,"))))) {:type :sci/error, :line 1, :column 19"))))
(deftest native-stacktrace-test (deftest native-stacktrace-test
(let [output (try (tu/bb nil "(merge 1 2 3)") (let [output (try (tu/bb nil "(merge 1 2 3)")