Skip to content

Fix Julia 1.12 compatibility for MethodList API change#217

Merged
cstjean merged 2 commits intoFluxML:masterfrom
ChrisRackauckas-Claude:fix-julia-1.12-methodlist-compat
Dec 29, 2025
Merged

Fix Julia 1.12 compatibility for MethodList API change#217
cstjean merged 2 commits intoFluxML:masterfrom
ChrisRackauckas-Claude:fix-julia-1.12-methodlist-compat

Conversation

@ChrisRackauckas-Claude
Copy link

Summary

  • Fix FieldError: type Base.MethodList has no field mt on Julia 1.12
  • Use version-conditional code: nameof(f) for Julia >= 1.12, original methods(f).mt.name for older versions
  • The prettify and unresolve functions now work correctly on Julia 1.12

Test plan

  • Verified fix works with MacroTools.prettify(Expr(:call, +, 1, 2)) on Julia 1.12.3
  • All 165 existing tests pass

Fixes #216

🤖 Generated with Claude Code

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 FluxML#216

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Member

@ChrisRackauckas ChrisRackauckas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this and the change seems reasonable.

@cstjean
Copy link
Collaborator

cstjean commented Dec 29, 2025

I don't mind merging this as is, but a test would be nice. prettify(:($sin(2))) or something.

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 <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Author

Added a test for prettify as suggested. The test verifies that function references like $sin are correctly resolved to their symbolic names:

@testset "prettify" begin
    @test MacroTools.prettify(:($sin(2))) == :(sin(2))
    @test MacroTools.prettify(:($cos(x))) == :(cos(x))
end

All 167 tests pass locally on Julia 1.12.3.

@cstjean cstjean merged commit 5315505 into FluxML:master Dec 29, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Julia 1.12 incompatibility: MethodList.mt field no longer exists

3 participants