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
History
File Mode Size
asan
bpftrace
mac
pgo-lto
tsan
windows
README.md -rw-r--r-- 2.9 KB
add_license_to_files.jl -rw-r--r-- 7.0 KB
check-whitespace.jl -rwxr-xr-x 2.0 KB
commit-name.sh -rwxr-xr-x 1.2 KB
debug_bootstrap.gdb -rw-r--r-- 76 bytes
delete-all-rpaths.sh -rwxr-xr-x 925 bytes
download_cmake.sh -rwxr-xr-x 2.1 KB
excise_stdlib.sh -rwxr-xr-x 967 bytes
fixup-libgfortran.sh -rwxr-xr-x 6.0 KB
fixup-libstdc++.sh -rwxr-xr-x 1.1 KB
fixup-rpath.sh -rwxr-xr-x 1.0 KB
generate_precompile.jl -rw-r--r-- 17.2 KB
httpbin-prod-swagger-apigateway.yaml -rw-r--r-- 3.0 KB
install.sh -rwxr-xr-x 695 bytes
julia-config.jl -rwxr-xr-x 3.6 KB
julia.appdata.xml -rw-r--r-- 1.4 KB
julia.desktop -rw-r--r-- 367 bytes
julia.png -rw-r--r-- 1.6 KB
julia.svg -rw-r--r-- 1.1 KB
new-stdlib.sh -rwxr-xr-x 1.8 KB
normalize_triplet.py -rwxr-xr-x 4.4 KB
prepare_release.sh -rwxr-xr-x 4.8 KB
print_sorted_stdlibs.jl -rw-r--r-- 3.1 KB
refresh_checksums.mk -rw-r--r-- 6.7 KB
relative_path.py -rwxr-xr-x 537 bytes
stringreplace.c -rw-r--r-- 942 bytes
updateSPDX.jl -rw-r--r-- 1.1 KB
valgrind-julia.supp -rw-r--r-- 156 bytes
write_base_cache.jl -rw-r--r-- 376 bytes

README.md

back to top