Skip to content

Commit

Permalink
Fix #906: merge-opts loses :features of previous context (#921)
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude authored Apr 22, 2024
1 parent a390739 commit bf6a0f1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ SCI is used in [babashka](https://github.com/babashka/babashka),

- Fix [#626](https://github.com/babashka/sci/issues/626): add `cljs.core/exists?`
- Fix [#919](https://github.com/babashka/sci/issues/919): :js-libs + refer + rename clashes with core var
- Fix [#906](https://github.com/babashka/sci/issues/906): `merge-opts` loses `:features` or previous context

## 0.8.41 (2023-11-24)

Expand Down
3 changes: 2 additions & 1 deletion src/sci/impl/opts.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@
#?(:cljs :js-libs)
:ns-aliases]
:or {load-fn (:load-fn env)
#?@(:cljs [async-load-fn (:async-load-fn env)])}} opts
#?@(:cljs [async-load-fn (:async-load-fn env)])
features (:features ctx)}} opts
raw-classes (merge (:raw-classes @!env) classes)
classes (normalize-classes raw-classes)
_ (init-env! !env bindings aliases namespaces classes raw-classes imports load-fn #?(:cljs async-load-fn) #?(:cljs js-libs) ns-aliases)
Expand Down
5 changes: 5 additions & 0 deletions test/sci/core_test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,11 @@
(swap! C sci/merge-opts {:namespaces {'n {'foo 2}}})
(is (= 2 (sci/eval-form @C 'n/foo)))))

(deftest merge-opts-preserves-features-test
(let [ctx(sci/init {:features #{:cljs}})]
(is (= 2 (sci/eval-string* ctx "#?(:clj 1 :cljs 2)")))
(is (= 2 (sci/eval-string* (sci/merge-opts ctx {}) "#?(:clj 1 :cljs 2)")))))

(deftest dynamic-meta-def-test
(is (= false (eval* "(def ^{:private (if (odd? 1) false true)} foo) (:private (meta #'foo))")))
(is (= "6" (eval* "(def ^{:doc (str (+ 1 2 3))} foo) (:doc (meta #'foo))")))
Expand Down

0 comments on commit bf6a0f1

Please sign in to comment.