# Trimming partially type erased functions

**URL:** <https://discourse.julialang.org/t/trimming-partially-type-erased-functions/136314>\
**Category:** General Usage\
**Tags:** trim\
**Created:** [March 20, 2026, 10:37pm UTC](https://discourse.julialang.org/t/trimming-partially-type-erased-functions/136314 "2026-03-20T22:37:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [March 20, 2026, 10:37pm UTC](https://discourse.julialang.org/t/trimming-partially-type-erased-functions/136314/1 "2026-03-20T22:37:33Z")

</div>

I’m using FunctionWrappers.jl to create type stable wrappers for functions I know input and output types. These functions are often closures created in local scopes. When trying to trim a function from FunctionWrappers.jl (or, better, a vector of those), compilation fails. Looking at this julia issue [RFC: TypedCallable · Issue #59774 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/59774) indeed it seems to confirm FunctionWrappers.jl is not compatible with trimming. The issue also proposes a very nice enhancement which would solve my problem, but still it isn’t implemented in Julia until today. So, I’m asking myself if also some other people encountered this issue before and/or know about techniques which can be used to trim a vector of functions with known inputs and outputs, even with no so great performance.

---

<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:** [March 22, 2026, 8:23pm UTC](https://discourse.julialang.org/t/trimming-partially-type-erased-functions/136314/2 "2026-03-22T20:23:20Z")

</div>

> [@Tortar](#):
>
> When trying to trim a function from [FunctionWrappers.jl](https://juliaregistries.github.io/General/packages/redirect_to_repo/FunctionWrappers) (or, better, a vector of those), compilation fails.

Really wonder why that is. My initial guess was that the trimmer doesn’t recognize the pointers to compiled code as reachable somehow (I have zero idea how finding reachable code works in the first place), but the `FunctionWrapper`’s pointers don’t line up with the method’s `CodeInstance`’s when I looked into it, and I failed to find good up-to-date documentation on what any of the fields mean.

---

<div class="post-metadata">

**Author:** ![Tortar](https://avatars.discourse-cdn.com/v4/letter/t/6bbea6/32.png) [@Tortar](https://discourse.julialang.org/u/Tortar)\
**Post date:** [March 22, 2026, 10:04pm UTC](https://discourse.julialang.org/t/trimming-partially-type-erased-functions/136314/3 "2026-03-22T22:04:43Z")

</div>

I’m not sure either why `FunctionWrapper`s can’t be trimmed, perhaps improving that implementation would make it possible to use this feature before the `TypedCallable` type lands into main Julia, but I don’t have any idea on what needs to be changed.
