Skip to content

Inference issue in Julia 1.12 #60398

@jakobnissen

Description

@jakobnissen

This is a duplicate of JuliaLang/JuliaC.jl#88, here reported upstream, as it is likely an inference failure in Julia that has stumped me. It's possible I did something dumb, but I can't figure it out.

To reproduce:

  1. Clone https://github.com/jakobnissen/AoC2025
  2. Check out commit 206a08a253bf7898d0cda32726ce0a658c7fcac0
  3. Outcomment line 181 in AoC2025.jl - the line containing println(Core.stdout, Day6.solve(ImmutableMemoryView(b"abc")))
  4. Attempt to compile with JuliaC 0.2.2, Julia 1.12.3. I used command juliac --output-exe aoc2025 --bundle build --trim=safe --experimental .

This will fail, with an unresolved call in AoC2025.solve. Some interesting observations:

  • The print statement at AoC2025.jl:181 somehow makes inference work
  • Changing the map at AoC2025.jl:184 to a for-loop that pushes to a vector also makes it infer, so maybe the issue is with map
  • Could it be a captured variable? Seems not; JET reports no such variables, and renaming solution in the closure makes no difference.
  • @code_warntype and JET both claim the relevant functions AoC2025.solve and AoC2025.Day6.solve are type stable and well-inferred. JET claims AoC2025.main "failed to optimize due to recursion", but none of the functions are recursive.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions