diff --git a/CHANGELOG.md b/CHANGELOG.md index d8b63ebf..240f412e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ For a list of breaking changes, check [here](#breaking-changes) - [#693](https://github.com/babashka/sci/issues/693): extend protocol to IRecord doesn't work on SCI records - [#695](https://github.com/babashka/sci/issues/695): `(identical? [] [])` works - [#700](https://github.com/babashka/sci/issues/700): loop doesn't expand in fully qualified let +- [#696](https://github.com/babashka/sci/issues/696): add let* special form ## v0.3.2 diff --git a/src/sci/impl/analyzer.cljc b/src/sci/impl/analyzer.cljc index 5ff74552..3c875edd 100644 --- a/src/sci/impl/analyzer.cljc +++ b/src/sci/impl/analyzer.cljc @@ -46,7 +46,7 @@ ;; derived from (keys (. clojure.lang.Compiler specials)) ;; (& monitor-exit case* try reify* finally loop* do letfn* if clojure.core/import* new deftype* let* fn* recur set! . var quote catch throw monitor-enter def) -(def special-syms '#{try finally do if new recur quote catch throw def . var set!}) +(def special-syms '#{try finally do if new recur quote catch throw def . var set! let*}) (defn- throw-error-with-location [msg node] (utils/throw-error-with-location msg node {:phase "analysis"})) @@ -457,7 +457,7 @@ (fn [iden->invoke-idx] (if (contains? iden->invoke-idx ob) iden->invoke-idx - (assoc iden->invoke-idx ob (+ #_arity (count iden->invoke-idx)))))))) + (assoc iden->invoke-idx ob (count iden->invoke-idx))))))) closure-idx (get-in new-cb (conj parents :syms ob))] closure-idx)) @@ -1220,6 +1220,7 @@ ;; every sub expression do (return-do ctx expr (rest expr)) let (analyze-let ctx expr) + let* (analyze-let* ctx expr (second expr) (nnext expr)) (fn fn*) (analyze-fn ctx expr false) def (analyze-def ctx expr) ;; NOTE: defn / defmacro aren't implemented as normal macros yet diff --git a/test/sci/core_test.cljc b/test/sci/core_test.cljc index 655c2024..66a7acca 100644 --- a/test/sci/core_test.cljc +++ b/test/sci/core_test.cljc @@ -166,7 +166,9 @@ '(let [x 3] (f) (f) x) {:bindings {'f #(swap! a inc)}}) @a))))) (testing "nested lets" - (is (= [2 1] (eval* "(let [x 1] [(let [x 2] x) x])"))))) + (is (= [2 1] (eval* "(let [x 1] [(let [x 2] x) x])")))) + (testing "let*" + (is (= [2 1] (eval* "(let* [x 1] [(let* [x 2] x) x])"))))) (deftest closure-test (testing "closure"