3fd7f1ae01774a4eb1ada2b6d78b98e19a242762 — Rob Browning 7 months ago c904eec main
Don't accidentally, implicitly :refer :all

Oops.  The code that generates the guile module #:select for a given
ns form acted as if every require included a :refer :all because it
defaulted the select value to #f all the time (for both use and
require), when it should have been choosing #f for use and () for
require, since guile treats a "#:select #f" like :refer :all.

i.e. in guile (use-modules (srfi srfi-1)) imports all of the srfi-1
exports into the current module, and (use-modules ((srfi srfi-1)
\#:select #f) behaves exactly the same way, while (use-modules ((srfi
srfi-1) #:select ()) imports nothing.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 files changed, 5 insertions(+), 1 deletions(-)

M mod/lokke/ns.scm
M test/clojure-ns
M mod/lokke/ns.scm => mod/lokke/ns.scm +3 -1
@@ 278,10 278,11 @@
    (dbgf "item it: ~s ~s\n" item it)
    (when (null? it)
      (error "Empty ns dependency reference:" item))
    ;; Note that select #f is effectively :refer :all.
    (let loop ((specs (cdr it))
               (alias #f)
               (select-src #f)
               (select #f)
               (select (if (eq? context 'use) #f '()))
               (hide '()))
      (dbgf "loop: ~s ~s ~s ~s ~s\n" specs alias select-src select hide)
      (if (null? specs)

@@ 390,6 391,7 @@
    (let ((interface (resolve-interface (ns-dep-spec-module spec))))
      (dbgf "mod-use: ~s\n" interface)
      (dbgf "mod-use: ~s\n" (module-public-interface interface)))
    ;; Note that #:select #f is effectively :refer :all.
    (module-use-interfaces! (current-module)
                            (list (resolve-interface (ns-dep-spec-module spec)
                                                     #:select (ns-dep-spec-select spec)

M test/clojure-ns => test/clojure-ns +2 -0
@@ 16,6 16,8 @@
(begin-tests (ns-name *ns*))

(is (= 'test.clojure-ns (ns-name *ns*)))
;; FIXME: rewrite using resolve/ns-resolve once they're added
(is (not (guile/module-variable (guile/current-module) 'join)))
(is (= clojure.string/join str/join))
(is (= seq (deref (find-var 'clojure.core/seq))))
(is (integer? (guile/current-time)))