Skip to content

Commit a885ba7

Browse files
committed
Deprecate expand(module, ex) to Meta.lower(module, ex).
1 parent 175f7a1 commit a885ba7

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ Deprecated or removed
383383
which now require a module argument.
384384
And it caused the bugfix of other default arguments to use the Main module (including `whos`, `which`).
385385

386+
* `expand(ex)` and `expand(module, ex)` have been deprecated in favor of
387+
`Meta.lower(ex)` ([#24278]).
388+
386389
* The `Operators` module is deprecated. Instead, import required operators explicitly
387390
from `Base`, e.g. `import Base: +, -, *, /` ([#22251]).
388391

base/client.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function eval_user_input(@nospecialize(ast), show_value)
153153
display_error(lasterr,bt)
154154
errcount, lasterr = 0, ()
155155
else
156-
ast = expand(Main, ast)
156+
ast = Meta.lower(Main, ast)
157157
value = eval(Main, ast)
158158
eval(Main, Expr(:body, Expr(:(=), :ans, QuoteNode(value)), Expr(:return, nothing)))
159159
if !(value === nothing) && show_value
@@ -210,7 +210,7 @@ function parse_input_line(s::String; filename::String="none")
210210
s, sizeof(s), filename, sizeof(filename))
211211
if ex isa Symbol && all(equalto('_'), string(ex))
212212
# remove with 0.7 deprecation
213-
expand(Main, ex) # to get possible warning about using _ as an rvalue
213+
Meta.lower(Main, ex) # to get possible warning about using _ as an rvalue
214214
end
215215
return ex
216216
end

base/deprecated.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,9 +1254,10 @@ _current_module() = ccall(:jl_get_current_module, Ref{Module}, ())
12541254
depwarn("binding_module(symbol) is deprecated, use `binding_module(module, symbol)` instead.", :binding_module)
12551255
return binding_module(_current_module(), s)
12561256
end
1257+
export expand
12571258
@noinline function expand(@nospecialize(x))
1258-
depwarn("expand(x) is deprecated, use `expand(module, x)` instead.", :expand)
1259-
return expand(_current_module(), x)
1259+
depwarn("expand(x) is deprecated, use `Meta.lower(module, x)` instead.", :expand)
1260+
return Meta.lower(_current_module(), x)
12601261
end
12611262
@noinline function macroexpand(@nospecialize(x))
12621263
depwarn("macroexpand(x) is deprecated, use `macroexpand(module, x)` instead.", :macroexpand)

base/exports.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,6 @@ export
936936

937937
# syntax
938938
esc,
939-
expand,
940939
gensym,
941940
macroexpand,
942941
@macroexpand1,

base/expr.jl

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ copy_exprargs(x::Array{Any,1}) = Any[copy_exprs(a) for a in x]
4545
==(x::Expr, y::Expr) = x.head === y.head && isequal(x.args, y.args)
4646
==(x::QuoteNode, y::QuoteNode) = isequal(x.value, y.value)
4747

48-
"""
49-
expand(m, x)
50-
51-
Takes the expression `x` and returns an equivalent expression in lowered form
52-
for executing in module `m`.
53-
See also [`code_lowered`](@ref).
54-
"""
55-
expand(m::Module, @nospecialize(x)) = ccall(:jl_expand, Any, (Any, Any), x, m)
56-
5748
"""
5849
macroexpand(m::Module, x; recursive=true)
5950

base/interactiveutil.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ function gen_call_with_extracted_types(__module__, fcn, ex0)
417417
if isa(ex0, Expr) && ex0.head == :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions*
418418
return Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...})
419419
end
420-
ex = expand(__module__, ex0)
420+
ex = Meta.lower(__module__, ex0)
421421
exret = Expr(:none)
422422
if !isa(ex, Expr)
423423
exret = Expr(:call, :error, "expression is not a function call or symbol")

base/meta.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,13 @@ macro dump(expr)
5656
dump(expr)
5757
end
5858

59+
"""
60+
lower(m, x)
61+
62+
Takes the expression `x` and returns an equivalent expression in lowered form
63+
for executing in module `m`.
64+
See also [`code_lowered`](@ref).
65+
"""
66+
lower(m::Module, @nospecialize(x)) = ccall(:jl_expand, Any, (Any, Any), x, m)
67+
5968
end # module

0 commit comments

Comments
 (0)