diff --git a/NEWS.md b/NEWS.md index 8cddb17a825585..aedf39a84cad18 100644 --- a/NEWS.md +++ b/NEWS.md @@ -40,6 +40,8 @@ Language changes * The syntax `(;)` (which was deprecated in v1.4) now creates an empty named tuple ([#30115]). +* `@inline` macro can now be applied to short-form anonymous functions ([#34953]). + * In triple-quoted string literals, whitespace stripping is now done before processing escape sequences instead of after. For example, the syntax ``` @@ -50,6 +52,7 @@ Language changes Now the result is "a\n b", since the space before `b` is no longer considered to occur at the start of a line. The old behavior is considered a bug ([#35001]). + Multi-threading changes ----------------------- diff --git a/base/expr.jl b/base/expr.jl index 0e7781f64c6433..4e7dd798cb21de 100644 --- a/base/expr.jl +++ b/base/expr.jl @@ -332,7 +332,7 @@ function is_short_function_def(ex) end function findmeta(ex::Expr) - if ex.head === :function || is_short_function_def(ex) + if ex.head === :function || is_short_function_def(ex) || ex.head === :-> body::Expr = ex.args[2] body.head === :block || error(body, " is not a block expression") return findmeta_block(ex.args) diff --git a/test/compiler/inline.jl b/test/compiler/inline.jl index 5dafed1e422f68..457f3aef079103 100644 --- a/test/compiler/inline.jl +++ b/test/compiler/inline.jl @@ -275,3 +275,10 @@ let ci = code_typed(f34900, Tuple{Int, Int})[1].first @test length(ci.code) == 1 && isexpr(ci.code[1], :return) && ci.code[1].args[1].id == 2 end + +@testset "check jl_ast_flag_inlineable for inline macro" begin + @test ccall(:jl_ast_flag_inlineable, Bool, (Any,), first(methods(@inline x -> x)).source) + @test !ccall(:jl_ast_flag_inlineable, Bool, (Any,), first(methods( x -> x)).source) + @test ccall(:jl_ast_flag_inlineable, Bool, (Any,), first(methods(@inline function f(x) x end)).source) + @test !ccall(:jl_ast_flag_inlineable, Bool, (Any,), first(methods(function f(x) x end)).source) +end