Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,11 @@ function makeif(clauses, els = nothing)
end

unresolve1(x) = x
unresolve1(f::Function) = methods(f).mt.name
@static if VERSION >= v"1.12-"
unresolve1(f::Function) = nameof(f)
else
unresolve1(f::Function) = methods(f).mt.name
end

unresolve(ex) = prewalk(unresolve1, ex)

Expand Down
6 changes: 6 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ end
@test flatten(quote begin; begin; f(); g(); end; begin; h(); end; f(); end; end) |> striplines == quote f(); g(); h(); f() end |> striplines
end

@testset "prettify" begin
# Test that prettify resolves function references to their names
@test MacroTools.prettify(:($sin(2))) == :(sin(2))
@test MacroTools.prettify(:($cos(x))) == :(cos(x))
end

@testset "flatten try" begin # see julia#50710 and MacroTools#194 # only tests that do not include `else` -- for the full set of tests see flatten_try.jl
exs = [
quote try; f(); catch; end; end,
Expand Down
Loading