diff --git a/NEWS.md b/NEWS.md index fe07847f836d7..4bc1e081379f3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -378,10 +378,13 @@ Deprecated or removed * The `bkfact`/`bkfact!` methods that accepted `uplo` and `issymmetric` symbols have been deprecated in favor of using `Hermitian` (or `Symmetric`) views ([#22605]). - * The function `current_module` is deprecated and replaced with `@__MODULE__` ([#22064]). - This caused the deprecation of some reflection methods (such as `macroexpand` and `isconst`), - which now require a module argument. - And it caused the bugfix of other default arguments to use the Main module (including `whos`, `which`). + * The function `current_module` is deprecated and replaced with `@__MODULE__`. + This caused the deprecation of some reflection methods (such as `macroexpand` and + `isconst`), which now require a module argument. And it caused the bugfix of other + default arguments to use the Main module (including `whos`, `which`) ([#22064]). + + * `expand(ex)` and `expand(module, ex)` have been deprecated in favor of + `Meta.lower(module, ex)` ([#22064, #24278]). * The `Operators` module is deprecated. Instead, import required operators explicitly from `Base`, e.g. `import Base: +, -, *, /` ([#22251]). diff --git a/base/client.jl b/base/client.jl index f38e655724840..9ac24a6aa4b45 100644 --- a/base/client.jl +++ b/base/client.jl @@ -153,7 +153,7 @@ function eval_user_input(@nospecialize(ast), show_value) display_error(lasterr,bt) errcount, lasterr = 0, () else - ast = expand(Main, ast) + ast = Meta.lower(Main, ast) value = eval(Main, ast) eval(Main, Expr(:body, Expr(:(=), :ans, QuoteNode(value)), Expr(:return, nothing))) if !(value === nothing) && show_value @@ -210,7 +210,7 @@ function parse_input_line(s::String; filename::String="none") s, sizeof(s), filename, sizeof(filename)) if ex isa Symbol && all(equalto('_'), string(ex)) # remove with 0.7 deprecation - expand(Main, ex) # to get possible warning about using _ as an rvalue + Meta.lower(Main, ex) # to get possible warning about using _ as an rvalue end return ex end diff --git a/base/deprecated.jl b/base/deprecated.jl index fce361c891a24..c79290409f1fa 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1254,9 +1254,10 @@ _current_module() = ccall(:jl_get_current_module, Ref{Module}, ()) depwarn("binding_module(symbol) is deprecated, use `binding_module(module, symbol)` instead.", :binding_module) return binding_module(_current_module(), s) end +export expand @noinline function expand(@nospecialize(x)) - depwarn("expand(x) is deprecated, use `expand(module, x)` instead.", :expand) - return expand(_current_module(), x) + depwarn("expand(x) is deprecated, use `Meta.lower(module, x)` instead.", :expand) + return Meta.lower(_current_module(), x) end @noinline function macroexpand(@nospecialize(x)) depwarn("macroexpand(x) is deprecated, use `macroexpand(module, x)` instead.", :macroexpand) diff --git a/base/exports.jl b/base/exports.jl index 09fd49d701fb2..99261587cebc0 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -936,7 +936,6 @@ export # syntax esc, - expand, gensym, macroexpand, @macroexpand1, diff --git a/base/expr.jl b/base/expr.jl index d3138e1a0ac23..f9edcc481e2ff 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -45,15 +45,6 @@ copy_exprargs(x::Array{Any,1}) = Any[copy_exprs(a) for a in x] ==(x::Expr, y::Expr) = x.head === y.head && isequal(x.args, y.args) ==(x::QuoteNode, y::QuoteNode) = isequal(x.value, y.value) -""" - expand(m, x) - -Takes the expression `x` and returns an equivalent expression in lowered form -for executing in module `m`. -See also [`code_lowered`](@ref). -""" -expand(m::Module, @nospecialize(x)) = ccall(:jl_expand, Any, (Any, Any), x, m) - """ macroexpand(m::Module, x; recursive=true) diff --git a/base/interactiveutil.jl b/base/interactiveutil.jl index 66c880e478dae..a9435c782a19a 100644 --- a/base/interactiveutil.jl +++ b/base/interactiveutil.jl @@ -417,7 +417,7 @@ function gen_call_with_extracted_types(__module__, fcn, ex0) if isa(ex0, Expr) && ex0.head == :macrocall # Make @edit @time 1+2 edit the macro by using the types of the *expressions* return Expr(:call, fcn, esc(ex0.args[1]), Tuple{#=__source__=#LineNumberNode, #=__module__=#Module, Any[ Core.Typeof(a) for a in ex0.args[3:end] ]...}) end - ex = expand(__module__, ex0) + ex = Meta.lower(__module__, ex0) exret = Expr(:none) if !isa(ex, Expr) exret = Expr(:call, :error, "expression is not a function call or symbol") diff --git a/base/meta.jl b/base/meta.jl index 349b410ce9668..fa0bac8904b99 100644 --- a/base/meta.jl +++ b/base/meta.jl @@ -56,4 +56,13 @@ macro dump(expr) dump(expr) end +""" + lower(m, x) + +Takes the expression `x` and returns an equivalent expression in lowered form +for executing in module `m`. +See also [`code_lowered`](@ref). +""" +lower(m::Module, @nospecialize(x)) = ccall(:jl_expand, Any, (Any, Any), x, m) + end # module diff --git a/base/repl/REPLCompletions.jl b/base/repl/REPLCompletions.jl index d7b9a6c96b25e..d757da88ed82c 100644 --- a/base/repl/REPLCompletions.jl +++ b/base/repl/REPLCompletions.jl @@ -348,7 +348,7 @@ function get_type(sym::Expr, fn::Module) # try to analyze nests of calls. if this fails, try using the expanded form. val, found = try_get_type(sym, fn) found && return val, found - return try_get_type(expand(fn, sym), fn) + return try_get_type(Meta.lower(fn, sym), fn) end function get_type(sym, fn::Module) diff --git a/doc/src/devdocs/eval.md b/doc/src/devdocs/eval.md index 17290a8645e2e..93c69dc5e5db6 100644 --- a/doc/src/devdocs/eval.md +++ b/doc/src/devdocs/eval.md @@ -78,7 +78,7 @@ the expression. Macro expansion involves a handoff from [`eval()`](@ref) (in Jul function `jl_macroexpand()` (written in `flisp`) to the Julia macro itself (written in - what else - Julia) via `fl_invoke_julia_macro()`, and back. -Typically, macro expansion is invoked as a first step during a call to [`expand()`](@ref)/`jl_expand()`, +Typically, macro expansion is invoked as a first step during a call to [`Meta.lower()`](@ref)/`jl_expand()`, although it can also be invoked directly by a call to [`macroexpand()`](@ref)/`jl_macroexpand()`. ## [Type Inference](@id dev-type-inference) diff --git a/doc/src/devdocs/reflection.md b/doc/src/devdocs/reflection.md index f835bdac7b1dc..a7147f5d80736 100644 --- a/doc/src/devdocs/reflection.md +++ b/doc/src/devdocs/reflection.md @@ -91,12 +91,12 @@ julia> macroexpand(@__MODULE__, :(@edit println("")) ) The functions `Base.Meta.show_sexpr` and [`dump`](@ref) are used to display S-expr style views and depth-nested detail views for any expression. -Finally, the [`expand`](@ref) function gives the `lowered` form of any expression and is of +Finally, the [`Meta.lower`](@ref) function gives the `lowered` form of any expression and is of particular interest for understanding both macros and top-level statements such as function declarations and variable assignments: ```jldoctest -julia> expand(@__MODULE__, :(f() = 1) ) +julia> Meta.lower(@__MODULE__, :(f() = 1) ) :(begin $(Expr(:method, :f)) $(Expr(:method, :f, :((Core.svec)((Core.svec)((Core.Typeof)(f)), (Core.svec)())), CodeInfo(:(begin diff --git a/doc/src/stdlib/base.md b/doc/src/stdlib/base.md index 28ba188c6988d..ec6de1217b054 100644 --- a/doc/src/stdlib/base.md +++ b/doc/src/stdlib/base.md @@ -344,10 +344,10 @@ Base.@functionloc ```@docs Base.gc Base.gc_enable +Meta.lower Base.macroexpand Base.@macroexpand Base.@macroexpand1 -Base.expand Base.code_lowered Base.@code_lowered Base.code_typed diff --git a/test/broadcast.jl b/test/broadcast.jl index 512e1f44617b3..918de24004523 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -318,12 +318,12 @@ end # make sure scalars are inlined, which causes f.(x,scalar) to lower to a "thunk" import Base.Meta: isexpr -@test isexpr(expand(Main, :(f.(x,y))), :call) -@test isexpr(expand(Main, :(f.(x,1))), :thunk) -@test isexpr(expand(Main, :(f.(x,1.0))), :thunk) -@test isexpr(expand(Main, :(f.(x,$π))), :thunk) -@test isexpr(expand(Main, :(f.(x,"hello"))), :thunk) -@test isexpr(expand(Main, :(f.(x,$("hello")))), :thunk) +@test isexpr(Meta.lower(Main, :(f.(x,y))), :call) +@test isexpr(Meta.lower(Main, :(f.(x,1))), :thunk) +@test isexpr(Meta.lower(Main, :(f.(x,1.0))), :thunk) +@test isexpr(Meta.lower(Main, :(f.(x,$π))), :thunk) +@test isexpr(Meta.lower(Main, :(f.(x,"hello"))), :thunk) +@test isexpr(Meta.lower(Main, :(f.(x,$("hello")))), :thunk) # PR #17623: Fused binary operators @test [true] .* [true] == [true] diff --git a/test/ccall.jl b/test/ccall.jl index f9c5d53a8d2ba..2f26ba5fae1e1 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1252,18 +1252,18 @@ end f21104rt(Float64)) # test for malformed syntax errors -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (), x))) -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B,), x, y))) -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B,), x, y, z))) -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B,), x, y))) -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B,), x, y, z))) -@test Expr(:error, "more arguments than types for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B, C), x, y, z))) -@test Expr(:error, "more types than arguments for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B,),))) -@test Expr(:error, "more types than arguments for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B, C), ))) -@test Expr(:error, "more types than arguments for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B..., C...), ))) -@test Expr(:error, "only the trailing ccall argument type should have '...'") == expand(@__MODULE__, :(ccall(:fn, A, (B..., C...), x))) -@test Expr(:error, "only the trailing ccall argument type should have '...'") == expand(@__MODULE__, :(ccall(:fn, A, (B..., C...), x, y, z))) -@test Expr(:error, "more types than arguments for ccall") == expand(@__MODULE__, :(ccall(:fn, A, (B, C...), ))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (), x))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,), x, y))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,), x, y, z))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,), x, y))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,), x, y, z))) +@test Expr(:error, "more arguments than types for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B, C), x, y, z))) +@test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B,),))) +@test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B, C), ))) +@test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), ))) +@test Expr(:error, "only the trailing ccall argument type should have '...'") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x))) +@test Expr(:error, "only the trailing ccall argument type should have '...'") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B..., C...), x, y, z))) +@test Expr(:error, "more types than arguments for ccall") == Meta.lower(@__MODULE__, :(ccall(:fn, A, (B, C...), ))) # cfunction on non-function singleton struct CallableSingleton diff --git a/test/codegen.jl b/test/codegen.jl index d59ce83e018b2..10fd00e1638d0 100644 --- a/test/codegen.jl +++ b/test/codegen.jl @@ -67,7 +67,7 @@ end function test_jl_dump_compiles_toplevel_thunks() tfile = tempname() io = open(tfile, "w") - topthunk = expand(Main, :(for i in 1:10; end)) + topthunk = Meta.lower(Main, :(for i in 1:10; end)) ccall(:jl_dump_compiles, Void, (Ptr{Void},), io.handle) Core.eval(Main, topthunk) ccall(:jl_dump_compiles, Void, (Ptr{Void},), C_NULL) diff --git a/test/goto.jl b/test/goto.jl index b56cdf58b2064..11f1a9f024958 100644 --- a/test/goto.jl +++ b/test/goto.jl @@ -1,7 +1,6 @@ # This file is a part of Julia. License is MIT: https://julialang.org/license # Basic goto tests -expand(x) = Base.expand(@__MODULE__, x) function goto_test1() @goto a @@ -15,10 +14,10 @@ end @test eval(:(@label a)) === nothing @test Expr(:error, "label \"a\" referenced but not defined") == - expand(:(@goto a)) + Meta.lower(@__MODULE__, :(@goto a)) @test Expr(:error, "label \"a\" defined multiple times") == - expand(quote + Meta.lower(@__MODULE__, quote function goto_test2() @goto a @label a @@ -29,7 +28,7 @@ end @test Expr(:error, "label \"a\" referenced but not defined") == - expand(quote + Meta.lower(@__MODULE__, quote function goto_test3() @goto a return @@ -37,7 +36,7 @@ end end) @test Expr(:error, "misplaced label") == - expand(quote + Meta.lower(@__MODULE__, quote function goto_test4() @goto a try @@ -60,7 +59,7 @@ macro goto_test5_macro3() end @test Expr(:error, "label \"a\" referenced but not defined") == - expand(quote + Meta.lower(@__MODULE__, quote function goto_test5_1() @goto a @goto_test5_macro1 @@ -68,7 +67,7 @@ end end end) -let e = expand(quote +let e = Meta.lower(@__MODULE__, quote function goto_test5_2() @goto_test5_macro2 @label a @@ -89,7 +88,7 @@ end @test Expr(:error, "goto from a try/finally block is not permitted") == - expand(quote + Meta.lower(@__MODULE__, quote function goto_test6() try @goto a diff --git a/test/parse.jl b/test/parse.jl index 91cb09af425b7..608de561caa35 100644 --- a/test/parse.jl +++ b/test/parse.jl @@ -498,7 +498,7 @@ test_parseerror("0x0.1", "hex float literal must contain \"p\" or \"P\"") test_parseerror("0x1.0p", "invalid numeric constant \"0x1.0\"") # issue #15798 -@test expand(Main, Base.parse_input_line(""" +@test Meta.lower(Main, Base.parse_input_line(""" try = "No" """)) == Expr(:error, "unexpected \"=\"") @@ -527,10 +527,10 @@ test_parseerror("if\nfalse\nend", "missing condition in \"if\" at none:1") test_parseerror("if false\nelseif\nend", "missing condition in \"elseif\" at none:2") # issue #15828 -@test expand(Main, parse("x...")) == Expr(:error, "\"...\" expression outside call") +@test Meta.lower(Main, parse("x...")) == Expr(:error, "\"...\" expression outside call") # issue #15830 -@test expand(Main, parse("foo(y = (global x)) = y")) == Expr(:error, "misplaced \"global\" declaration") +@test Meta.lower(Main, parse("foo(y = (global x)) = y")) == Expr(:error, "misplaced \"global\" declaration") # issue #15844 function f15844(x) @@ -561,11 +561,11 @@ add_method_to_glob_fn!() @test_throws ParseError parse("function finally() end") # PR #16170 -@test expand(Main, parse("true(x) = x")) == Expr(:error, "invalid function name \"true\"") -@test expand(Main, parse("false(x) = x")) == Expr(:error, "invalid function name \"false\"") +@test Meta.lower(Main, parse("true(x) = x")) == Expr(:error, "invalid function name \"true\"") +@test Meta.lower(Main, parse("false(x) = x")) == Expr(:error, "invalid function name \"false\"") # issue #16355 -@test expand(Main, :(f(d:Int...) = nothing)) == Expr(:error, "\"d:Int\" is not a valid function argument name") +@test Meta.lower(Main, :(f(d:Int...) = nothing)) == Expr(:error, "\"d:Int\" is not a valid function argument name") # issue #16517 @test (try error(); catch; 0; end) === 0 @@ -721,21 +721,21 @@ let m_error, error_out, filename = Base.source_path() end # issue #7272 -@test expand(Main, parse("let +@test Meta.lower(Main, parse("let global x = 2 local x = 1 end")) == Expr(:error, "variable \"x\" declared both local and global") -@test expand(Main, parse("let +@test Meta.lower(Main, parse("let local x = 2 local x = 1 end")) == Expr(:error, "local \"x\" declared twice") -@test expand(Main, parse("let x +@test Meta.lower(Main, parse("let x local x = 1 end")) == Expr(:error, "local \"x\" declared twice") -@test expand(Main, parse("let x = 2 +@test Meta.lower(Main, parse("let x = 2 local x = 1 end")) == Expr(:error, "local \"x\" declared twice") @@ -743,7 +743,7 @@ end @test :(let $([:(x=1),:(y=2)]...); x+y end) == :(let x = 1, y = 2; x+y end) # make sure front end can correctly print values to error messages -let ex = expand(Main, parse("\"a\"=1")) +let ex = Meta.lower(Main, parse("\"a\"=1")) @test ex == Expr(:error, "invalid assignment location \"\"a\"\"") end @@ -763,7 +763,7 @@ for (str, tag) in Dict("" => :none, "\"" => :string, "#=" => :comment, "'" => :c end # meta nodes for optional positional arguments -@test expand(Main, :(@inline f(p::Int=2) = 3)).args[2].args[3].inlineable +@test Meta.lower(Main, :(@inline f(p::Int=2) = 3)).args[2].args[3].inlineable # issue #16096 module M16096 @@ -775,14 +775,14 @@ macro iter() end end end -let ex = expand(M16096, :(@iter)) +let ex = Meta.lower(M16096, :(@iter)) @test isa(ex, Expr) && ex.head === :thunk end -let ex = expand(Main, :($M16096.@iter)) +let ex = Meta.lower(Main, :($M16096.@iter)) @test isa(ex, Expr) && ex.head === :thunk end let thismodule = @__MODULE__, - ex = expand(thismodule, :(@M16096.iter)) + ex = Meta.lower(thismodule, :(@M16096.iter)) @test isa(ex, Expr) && ex.head === :thunk @test !isdefined(M16096, :foo16096) local_foo16096 = eval(@__MODULE__, ex) @@ -848,11 +848,11 @@ for op in ["+", "-", "\$", "|", ".+", ".-", "*", ".*"] end # issue #17701 -@test expand(Main, :(i==3 && i+=1)) == Expr(:error, "invalid assignment location \"==(i, 3) && i\"") +@test Meta.lower(Main, :(i==3 && i+=1)) == Expr(:error, "invalid assignment location \"==(i, 3) && i\"") # issue #18667 -@test expand(Main, :(true = 1)) == Expr(:error, "invalid assignment location \"true\"") -@test expand(Main, :(false = 1)) == Expr(:error, "invalid assignment location \"false\"") +@test Meta.lower(Main, :(true = 1)) == Expr(:error, "invalid assignment location \"true\"") +@test Meta.lower(Main, :(false = 1)) == Expr(:error, "invalid assignment location \"false\"") # PR #15592 let str = "[1] [2]" @@ -924,10 +924,10 @@ macro m4() end end """, "another_file.jl") -m1_exprs = get_expr_list(expand(@__MODULE__, :(@m1))) -m2_exprs = get_expr_list(expand(@__MODULE__, :(@m2))) -m3_exprs = get_expr_list(expand(@__MODULE__, :(@m3))) -m4_exprs = get_expr_list(expand(@__MODULE__, :(@m4))) +m1_exprs = get_expr_list(Meta.lower(@__MODULE__, :(@m1))) +m2_exprs = get_expr_list(Meta.lower(@__MODULE__, :(@m2))) +m3_exprs = get_expr_list(Meta.lower(@__MODULE__, :(@m3))) +m4_exprs = get_expr_list(Meta.lower(@__MODULE__, :(@m4))) # Check the expanded expresion has expected number of matching push/pop # and the return is handled correctly @@ -1010,7 +1010,7 @@ end @test parse("Foo{T} = Bar{T}") == Expr(:(=), Expr(:curly, :Foo, :T), Expr(:curly, :Bar, :T)) # don't insert push_loc for filename `none` at the top level -let ex = expand(Main, parse(""" +let ex = Meta.lower(Main, parse(""" begin x = 1 end""")) @@ -1097,8 +1097,8 @@ end # issue #20541 @test parse("[a .!b]") == Expr(:hcat, :a, Expr(:call, :(.!), :b)) -@test expand(Main, :(a{1} = b)) == Expr(:error, "invalid type parameter name \"1\"") -@test expand(Main, :(a{2<:Any} = b)) == Expr(:error, "invalid type parameter name \"2\"") +@test Meta.lower(Main, :(a{1} = b)) == Expr(:error, "invalid type parameter name \"1\"") +@test Meta.lower(Main, :(a{2<:Any} = b)) == Expr(:error, "invalid type parameter name \"2\"") # issue #20653 @test_throws UndefVarError Base.call(::Int) = 1 @@ -1120,13 +1120,13 @@ macro m20729() end @test_throws ErrorException eval(@__MODULE__, :(@m20729)) -@test expand(@__MODULE__, :(@m20729)) == Expr(:error, "undefined reference in AST") +@test Meta.lower(@__MODULE__, :(@m20729)) == Expr(:error, "undefined reference in AST") macro err20000() return Expr(:error, "oops!") end -@test expand(@__MODULE__, :(@err20000)) == Expr(:error, "oops!") +@test Meta.lower(@__MODULE__, :(@err20000)) == Expr(:error, "oops!") # issue #20000 @test parse("@m(a; b=c)") == Expr(:macrocall, Symbol("@m"), LineNumberNode(1, :none), @@ -1144,8 +1144,8 @@ g21054(>:) = >:2 @test g21054(-) == -2 # issue #21168 -@test expand(Main, :(a.[1])) == Expr(:error, "invalid syntax a.[1]") -@test expand(Main, :(a.{1})) == Expr(:error, "invalid syntax a.{1}") +@test Meta.lower(Main, :(a.[1])) == Expr(:error, "invalid syntax a.[1]") +@test Meta.lower(Main, :(a.{1})) == Expr(:error, "invalid syntax a.{1}") # Issue #21225 let abstr = parse("abstract type X end") @@ -1249,7 +1249,7 @@ module Test21607 end # issue #16937 -@test expand(Main, :(f(2, a=1, w=3, c=3, w=4, b=2))) == +@test Meta.lower(Main, :(f(2, a=1, w=3, c=3, w=4, b=2))) == Expr(:error, "keyword argument \"w\" repeated in call to \"f\"") let f(x) = @@ -1300,7 +1300,7 @@ end @test_throws ParseError parse("@ time") # issue #7479 -@test expand(Main, parse("(true &&& false)")) == Expr(:error, "misplaced \"&\" expression") +@test Meta.lower(Main, parse("(true &&& false)")) == Expr(:error, "misplaced \"&\" expression") # if an indexing expression becomes a cat expression, `end` is not special @test_throws ParseError parse("a[end end]") @@ -1342,7 +1342,7 @@ let end # issue #18730 -@test expand(Main, quote +@test Meta.lower(Main, quote function f() local Int x::Int -> 2 diff --git a/test/reflection.jl b/test/reflection.jl index 306456d78389d..0ea416be7df5f 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -88,7 +88,7 @@ tag = Base.have_color ? Base.text_colors[Base.error_color()] : "ARRAY{FLOAT64,N} # Make sure emphasis is not used for other functions tag = Base.have_color ? Base.text_colors[Base.error_color()] : "ANY" iob = IOBuffer() -show(iob, expand(Main, :(x -> x^2))) +show(iob, Meta.lower(Main, :(x -> x^2))) str = String(take!(iob)) @test isempty(search(str, tag)) diff --git a/test/stacktraces.jl b/test/stacktraces.jl index 55b5ea1f1678c..d048a448b4a1b 100644 --- a/test/stacktraces.jl +++ b/test/stacktraces.jl @@ -98,7 +98,7 @@ for (frame, func, inlined) in zip(trace, [g,h,f], (can_inline, can_inline, false end end -let src = expand(Main, quote let x = 1 end end).args[1]::CodeInfo, +let src = Meta.lower(Main, quote let x = 1 end end).args[1]::CodeInfo, li = ccall(:jl_new_method_instance_uninit, Ref{Core.MethodInstance}, ()), sf diff --git a/test/strings/basic.jl b/test/strings/basic.jl index e413543b4f56d..d2039a22e746f 100644 --- a/test/strings/basic.jl +++ b/test/strings/basic.jl @@ -70,7 +70,7 @@ end sym = Symbol(Char(0xdcdb)) @test string(sym) == string(Char(0xdcdb)) @test String(sym) == string(Char(0xdcdb)) - @test expand(Main, sym) === sym + @test Meta.lower(Main, sym) === sym res = string(parse(string(Char(0xdcdb)," = 1"),1,raise=false)[1]) @test res == """\$(Expr(:error, "invalid character \\\"\\udcdb\\\"\"))""" end