Make (require [foo [*]]) pull in macros required by foo

This commit is contained in:
Kodi Arfer 2019-01-16 08:02:01 -05:00
parent a5ed98f5b9
commit 983ea2dda2
2 changed files with 10 additions and 11 deletions

View File

@ -190,14 +190,9 @@ def require(source_module, target_module, assignments, prefix=""):
prefix += "."
if assignments == "ALL":
# Only add macros/tags created in/by the source module.
name_assigns = [(n, n) for n, f in source_macros.items()
if inspect.getmodule(f) == source_module]
name_assigns += [(n, n) for n, f in source_tags.items()
if inspect.getmodule(f) == source_module]
name_assigns = [(k, k) for k in
tuple(source_macros.keys()) + tuple(source_tags.keys())]
else:
# If one specifically requests a macro/tag not created in the source
# module, I guess we allow it?
name_assigns = assignments
for name, alias in name_assigns:

View File

@ -378,10 +378,6 @@ in expansions."
(require [tests.resources.macro-with-require [*]])
;; Make sure our local version wasn't overwritten by a faulty `require` of the
;; one in tests.resources.macro-with-require.
(assert (= nonlocal-test-macro (get __macros__ "nonlocal_test_macro")))
(setv module-name-var "tests.native_tests.native_macros.test-macro-namespace-resolution")
(assert (= (+ "This macro was created in tests.resources.macros, "
"expanded in tests.native_tests.native_macros.test-macro-namespace-resolution "
@ -479,3 +475,11 @@ in expansions."
;; ensure that an imported module used the cached bytecode. We'll simply have
;; to trust that the .pyc loading convention was followed.
(test-requires-and-macros))
(defn test-recursive-require-star []
"(require [foo [*]]) should pull in macros required by `foo`."
(require [tests.resources.macro-with-require [*]])
(test-macro)
(assert (= blah 1)))