diff --git a/JuliaSyntax/src/integration/expr.jl b/JuliaSyntax/src/integration/expr.jl index 0783ee3f04e5c..fd7c93dfda3f9 100644 --- a/JuliaSyntax/src/integration/expr.jl +++ b/JuliaSyntax/src/integration/expr.jl @@ -528,8 +528,9 @@ end elseif k == K"function" if length(args) > 1 if has_flags(nodehead, SHORT_FORM_FUNCTION_FLAG) + a1 = args[1] a2 = args[2] - if !@isexpr(a2, :block) + if !@isexpr(a2, :block) && !@isexpr(a1, Symbol("'")) args[2] = Expr(:block, a2) end retexpr.head = :(=) diff --git a/JuliaSyntax/test/expr.jl b/JuliaSyntax/test/expr.jl index d7547848bef09..828d0a92e8b89 100644 --- a/JuliaSyntax/test/expr.jl +++ b/JuliaSyntax/test/expr.jl @@ -269,6 +269,12 @@ Expr(:block, LineNumberNode(3))) + # short-form postfix function shouldn't introduce a block + @test parsestmt("x' = 1") == + Expr(:(=), + Expr(Symbol("'"), :x), + 1) + # `.=` doesn't introduce short form functions @test parsestmt("f() .= xs") == Expr(:(.=), Expr(:call, :f), :xs)