From 3d396e72dfbcf6f2f3494be43028163fa00372e4 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Sun, 28 Dec 2025 20:03:31 -0500 Subject: [PATCH 1/2] Fix Julia 1.12 compatibility for MethodList API change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Julia 1.12, `Base.MethodList` no longer has the `mt` field. Use `nameof(f)` for Julia >= 1.12 to get the function name. Fixes #216 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/utils.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils.jl b/src/utils.jl index 1d1619f..784da27 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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) From 6990d348c89f80c8153fdd635634fa23161f1d55 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Sun, 28 Dec 2025 21:27:54 -0500 Subject: [PATCH 2/2] Add test for prettify function resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test that prettify correctly resolves function references (like $sin) to their symbolic names (sin). This exercises the unresolve functionality which was fixed for Julia 1.12 compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- test/utils.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/utils.jl b/test/utils.jl index 34621f2..f1b5765 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -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,