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
Raw File
CITATION.cff
# Official format description at https://citation-file-format.github.io
cff-version: 1.2.0
message: "Cite this paper whenever you use Julia"
authors:
- family-names: "Bezanson"
  given-names: "Jeff"
- family-names: "Edelman"
  given-names: "Alan"
- family-names: "Karpinski"
  given-names: "Stefan"
- family-names: "Shah"
  given-names: "Viral B."
title: "Julia: A fresh approach to numerical computing"
version: "v1"
license: "MIT"
doi: "10.1137/141000671"
date-released: 2017-02-07
url: "https://julialang.org"
preferred-citation:
  authors:
    - family-names: "Bezanson"
      given-names: "Jeff"
    - family-names: "Edelman"
      given-names: "Alan"
    - family-names: "Karpinski"
      given-names: "Stefan"
    - family-names: "Shah"
      given-names: "Viral B."
  doi: "10.1137/141000671"
  journal: "SIAM Review"
  month: 9
  start: 65
  end: 98
  pages: 33
  title: "Julia: A fresh approach to numerical computing"
  type: article
  volume: 59
  issue: 1
  year: 2017
  publisher:
    name: "SIAM"
back to top