Revision 63e365feb8692b9d7cb5298954c26ab7af268171 authored by Keno Fischer on 23 March 2024, 05:18:55 UTC, committed by GitHub on 23 March 2024, 05:18:55 UTC
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.
1 parent 6172020
VERSION
1.12.0-DEV
Computing file changes ...