-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REPL: Expand macros before looking for
using
statements
Currently, in order to give the nice prompt for missing packages, we look for any `using`/`import` statements in the AST before evaluation. However, this misses any `using` statements introduced by macros: ``` julia> using Pkg julia> using BenchmarkTools │ Package BenchmarkTools not found, but a package named BenchmarkTools is │ available from a registry. │ Install package? │ (@v1.11) pkg> add BenchmarkTools └ (y/n/o) [y]: n ERROR: ArgumentError: Package BenchmarkTools not found in current path. - Run `import Pkg; Pkg.add("BenchmarkTools")` to install the BenchmarkTools package. Stacktrace: [1] macro expansion @ Base ./loading.jl:1781 [inlined] [2] macro expansion @ Base ./lock.jl:267 [inlined] [3] __require(into::Module, mod::Symbol) @ Base ./loading.jl:1762 [4] #invoke_in_world#3 @ Base ./essentials.jl:963 [inlined] [5] invoke_in_world @ Base ./essentials.jl:960 [inlined] [6] require(into::Module, mod::Symbol) @ Base ./loading.jl:1755 julia> macro foo() :(using BenchmarkTools) end @foo (macro with 1 method) julia> @foo ERROR: ArgumentError: Package BenchmarkTools not found in current path. - Run `import Pkg; Pkg.add("BenchmarkTools")` to install the BenchmarkTools package. Stacktrace: [1] macro expansion @ Base ./loading.jl:1781 [inlined] [2] macro expansion @ Base ./lock.jl:267 [inlined] [3] __require(into::Module, mod::Symbol) @ Base ./loading.jl:1762 [4] #invoke_in_world#3 @ Base ./essentials.jl:963 [inlined] [5] invoke_in_world @ Base ./essentials.jl:960 [inlined] [6] require(into::Module, mod::Symbol) @ Base ./loading.jl:1755 [7] top-level scope @ REPL[4]:1 ``` Generally, it doesn't matter, but embedded DSLs may want to do this kind of thing, so we might as well try to support it.
- Loading branch information
Showing
3 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters