# AI-generated enhancements and examples for StaticCompiler.jl

**URL:** <https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054>\
**Category:** Tooling\
**Tags:** staticcompiler\
**Created:** [November 23, 2025, 9:02am UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054 "2025-11-23T09:02:33Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 23, 2025, 3:41pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/21 "2025-11-23T15:41:09Z")

</div>

Have you read, understood and reviewed the code yourself? I don’t have particularly strong feeling about using these tools to generate code, but I do have strong feeling about having responsible humans review and understand their results.

I suspect you haven’t reviewed the code yourself here, so that makes me very hesitant to do the huge amount of work to even begin evaluating the quality, design decisions, and potential failure modes.

Showing up with no standing and no prior engagement and then dumping gigantic chatbot generated PRs that do tonnes of different things that could easily be broken down into smaller chunks, and then falsely claiming that it couldn’t possibly be broken down into smaller pieces is not a good way to start this process or get reviewers on board.

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 23, 2025, 5:33pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/22 "2025-11-23T17:33:31Z")

</div>

The PR can certainly be broken down further, starting with the Julia 1.12 upgrade.

I intend to get to it next week.

I the meantime, feel free to run through the examples using my build.

---

<div class="post-metadata">

**Author:** ![xal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xal/32/215106_2.png) [@xal](https://discourse.julialang.org/u/xal)\
**Post date:** [November 23, 2025, 6:08pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/23 "2025-11-23T18:08:15Z")

</div>

The added features don’t work. None of the analyses I looked at in the `src/analyses/` directory do what they claim, and the “tests” all seem to check that they return nothing. I found this funny:

```julia-auto
function estimate_method_targets(func_name::Symbol, types::Tuple)
    # Conservative estimate
    # In a real implementation, we'd query the method table
    return 2 # Assume multiple possibilities
end

```

Did you read any of this?

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 23, 2025, 6:11pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/24 "2025-11-23T18:11:01Z")

</div>

I will have to.

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 23, 2025, 6:14pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/25 "2025-11-23T18:14:42Z")

</div>

It knows what it’s doing but tends to be… lazy.

› Why not actually implement all the analysis and do the tests properly?

• Fair point—we should either implement them or drop them. I can replace the

- Devirtualization: walk code\_typed for :invoke/Core.\_apply\_iterate calls,  
collect callee types, count concrete vs multi-target dispatch using methods/  
hasmethod against the specialization signature. Populate CallSiteInfo with real  
num\_targets, can\_devirtualize, and dynamic\_dispatch.
- Escape analysis: stop guessing sizes; use code\_typed to count allocation nodes  
(:call to Array, Base.allocatedinline, Expr(:new)), and mark escapes/can\_promote  
based on SSA use analysis (does result feed stores or leave the function). Size  
estimates can use element type and literal dims when available.
- Monomorphization: flag abstract parameter types by inspecting the signature and  
code\_warntype/code\_typed body to compute a simple specialization factor (e.g.,  
ratio of concrete to total slot types).
- Constant propagation: scan IR for literal operands and dead branches; count  
and count potential leaks and double frees by following SSA uses and return  
paths.
- Suggestions: tie into the above metrics (e.g., only suggest stack promotion when  
escapes==false and can\_promote==true).
- Tests: assert on report fields (scores, counts) for crafted fixtures that  
exercise each path (single vs multi-target call, escaping allocation, missing  
free, constant branch).

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 23, 2025, 6:22pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/26 "2025-11-23T18:22:09Z")

</div>

Ultimately, what is missing is a process to have AI self-review while keeping itself honest.

Plus, help a human review the code.

Yes, you can keep AI honest but you have to remember to prompt it which I didn’t at the very end. Something along the lines of “are there any tests stubbed out and have you taken any shortcuts?”

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [November 23, 2025, 6:27pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/27 "2025-11-23T18:27:10Z")

</div>

Well, I’m feeling pretty justified in not wanting to review the PR.

For now, I’ve closed it as slop, but please feel free to try again and submit discrete PRs that do discrete things like e.g. upgrade to 1.11 / 1.12, or add certain features / analyses.

That said, if you do go and submit new PRs, please actually review and understand the code you’re submitting first. If I wanted an LLM to generate 20,000 lines of unreviewed code with fake tests, I could do it myself.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/224680_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [November 23, 2025, 6:29pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/28 "2025-11-23T18:29:46Z")

</div>

> [@joelreymont](#):
>
> It knows what it’s doing but tends to be… lazy.
> 
> › Why not actually implement all the analysis and do the tests properly?

Complaining that the LLM is lazy and then (presumably) _asking it_ what we could improve is pretty meta 🤣

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 23, 2025, 6:32pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/29 "2025-11-23T18:32:56Z")

</div>

It will literally say that _this is too hard, I’m gonna take this easier option and stub this out for now_. [This is not the best example](https://x.com/joelreymont/status/1992563246864437477?s=20) but it’s all I saved for now. I don’t know why it does that but it does.

So you do, actually, have to ask it if it has been honest and it will tell you if it has not been and exactly where.

---

<div class="post-metadata">

**Author:** ![csvance](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/csvance/32/218927_2.png) [@csvance](https://discourse.julialang.org/u/csvance)\
**Post date:** [November 23, 2025, 7:35pm UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/31 "2025-11-23T19:35:29Z")

</div>

Much of the actual work during software development is establishing a strong mental model of how your changes work together as part of a larger system and being able to communicate them effectively to the people reviewing and approving said changes. Whether the code is written by an LLM or not if you can’t do this chances are you need to do more work before having other people look at your changes.

---

<div class="post-metadata">

**Author:** ![kapple](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kapple/32/218915_2.png) [@kapple](https://discourse.julialang.org/u/kapple)\
**Post date:** [November 24, 2025, 5:09am UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/32 "2025-11-24T05:09:22Z")

</div>

@joelreymont I refer you to Chris Rackauckas’ excellent article on how to incorporate AI into your workflow.

> **[Claude Code sucks but is still useful: experiences maintaining Julia's SciML...](https://www.stochasticlifestyle.com/claude-code-in-scientific-computing-experiences-maintaining-julias-sciml-infrastructure/)**
>
> Claude Code sucks but is still useful: experiences maintaining Julia’s SciML scientific computing infrastructure So it’s pretty public that for about a month now I’ve had 32 processes setup on one of the 64 core 128gb RAM servers to just ssh in, tmux...

I don’t know how aprocryphal or misquoted this is but a quote I enjoy is “A couple of months in the laboratory can frequently save a couple of hours in the library.”

I encourage you to employ the strategies Chris concludes on in his article (“library”) to save you the time you’ll spend (“in the lab”).

Though with the quality of what you’ve submitted, it does look like you spent little time at all reading “your” own code.

Us in the Julia community are going to repeatedly reject your PRs unless your present something human-provably worthwhile.

We’d love to have you as a genuine addition to the Julia community. But please, I emphasise: “genuine.”

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [November 24, 2025, 9:24am UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/33 "2025-11-24T09:24:09Z")

</div>

> [@joelreymont](#):
>
> This PR would not make sense piecemeal, it either works as a whole or it doesn’t.

I wouldn’t be so quick to dismiss this. You favor the term “cooking”, and to press the analogy, a meal isn’t usually served as a monolith. There are several courses, each dish has several components and sides, diners can savor a bite at a time. Emergency ration bars are technically monoliths, but they’re actually not trivial to make. Chances are you do in fact have several dishes if you change your perspective.

For example, one of the features you introduced is a heap allocation check. Diving into one example `arr = [i for i in 1:n]` in your blogpost, the underlying routine is:

```julia-auto
julia> analyze_escapes(bad_code,(Int,))
EscapeAnalysisReport(AllocationInfo[AllocationInfo(true, 64, "line 19 (collect)", true)], 0, 0, :bad_code)

```

And the way that works is that `check_allocation_expr` examines lowered expressions for array-allocating functions like `collect`. Neat, let’s try another:

```julia-auto
julia> foo() = [1,2,3];

julia> analyze_escapes(foo,())
EscapeAnalysisReport(AllocationInfo[], 0, 0, :foo)

```

Uh oh, a miss. The problem is that expression lowers to `Base.vect`, and that is not among the function names that `check_allocation_expr` checks. You could add that one, but it’s not even close to a fix:

```julia-auto
julia> bar() = Ref(1);

julia> analyze_escapes(bar,())
EscapeAnalysisReport(AllocationInfo[], 0, 0, :bar)

```

Another miss, and I haven’t even tried it on new `mutable struct`s, methods for stack-allocated arrays, or these function names being assigned to entirely different things in other modules. Evidently, the AI’s reviews and tests were far less thorough than it appeared or claimed, and a StaticCompiler user would’ve immediately suffered the consequences had this PR been merged as is.

Meanwhile, the rest of your PR is blocked by this problem even if there were no other issues, and if this problem is fixed, the other completely unrelated problems in your PR (say, the overly strict check on abstract type annotations and dubious verification score cutoff) in turn block it from being merged. StaticCompiler may not even be the right place for these changes. Despite your intended application, static allocation checks do not necessarily concern AOT compilation without the runtime, and it could be a separate package entirely that is suggested as a dependency or as independent tooling (like StaticTools) for StaticCompiler. In fact, the AllocCheck.jl package does just that. I don’t know its limits, but it at least succeeds at the few examples here.

---

<div class="post-metadata">

**Author:** ![joelreymont](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joelreymont/32/206998_2.png) [@joelreymont](https://discourse.julialang.org/u/joelreymont)\
**Post date:** [November 24, 2025, 9:26am UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/34 "2025-11-24T09:26:06Z")

</div>

Thank you Benny!

---

<div class="post-metadata">

**Author:** ![Nick2bad4u](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nick2bad4u/32/219572_2.png) [@Nick2bad4u](https://discourse.julialang.org/u/Nick2bad4u)\
**Post date:** [November 28, 2025, 12:04am UTC](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054/35 "2025-11-28T00:04:44Z")

</div>

Not to jump in and be rude.

I mean this as a positive and constructive criticism, as it appears you really might not understand why people have an issue with this interaction.

I mean this in the best way -

But he spent probably quite a bit of his own time (that you didn’t) on reviewing the PR to give you legitimate feedback, and you can’t even spend the time to give him a proper response.

How about an apology? Or at least some recognition that you screwed up and need to do better in the future.

I don’t know if you know this or not but these lopsided interaction lead directly to a lot of Open source developers burning out. Please don’t be part of the problem.

[Previous page](https://discourse.julialang.org/t/ai-generated-enhancements-and-examples-for-staticcompiler-jl/134054.md?page=1)
