mirror of
https://github.com/janet-lang/janet
synced 2024-11-24 17:27:18 +00:00
Improve import's handling of non constant args.
Be much more conservative about which arguments are cast to strings.
This commit is contained in:
parent
86e00e865e
commit
17d0b7a985
@ -2475,7 +2475,8 @@
|
||||
to be called. Dynamic bindings will NOT be imported. Use :fresh to bypass the
|
||||
module cache."
|
||||
[path & args]
|
||||
(def argm (map |(if (keyword? $) $ (string $)) args))
|
||||
(def ps (partition 2 args))
|
||||
(def argm (mapcat (fn [[k v]] [k (if (= k :as) (string v) v)]) ps))
|
||||
(tuple import* (string path) ;argm))
|
||||
|
||||
(defmacro use
|
||||
|
@ -57,4 +57,8 @@
|
||||
(assert (= nil (curenv 1000000)) "curenv 3")
|
||||
(assert (= root-env (curenv 1)) "curenv 4")
|
||||
|
||||
# Import macro test
|
||||
(assert-no-error "import macro 1" (macex '(import a :as b :fresh maybe)))
|
||||
(assert (deep= ~(,import* "a" :as "b" :fresh maybe) (macex '(import a :as b :fresh maybe))) "import macro 2")
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user