# Wrong supertype for compiled sysimage

**URL:** https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090
**Category:** General Usage
**Created:** [October 17, 2023, 6:13pm UTC](https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090 "2023-10-17T18:13:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Kruxigt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kruxigt/32/11694_2.png) [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)
#### Post date: [October 17, 2023, 6:13pm UTC](https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090/1 "2023-10-17T18:13:09Z")

</div>

I have the following two functions in my code

```julia
function test_supertype1(t::Type)
    return supertype(t)
end

function test_supertype2(t::Type{T}) where T <: AssetLayer
    return supertype(t)
end

```

Normally both work as intended. However when I compile the code to a sysimage the second one `test_supertype2` gives the incorrect answer. For some reason it seems to always return `supertype(supertype(t))` instead of just `supertype(t)`.

Any idea why?

Julia v 1.10 Beta 3  
compile=all for the sysimage

---

<div class="post-metadata">

### Author: ![vchuravy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vchuravy/32/8_2.png) [@vchuravy](https://discourse.julialang.org/u/vchuravy)
#### Post date: [October 17, 2023, 6:15pm UTC](https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090/2 "2023-10-17T18:15:47Z")

</div>

Can you produce a MWE? With removing `AssetLayer` I couldn’t reproduce it.

Best to file this as a bug under `https://github.com/JuliaLang/julia`

---

<div class="post-metadata">

### Author: ![Kruxigt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kruxigt/32/11694_2.png) [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)
#### Post date: [October 17, 2023, 6:18pm UTC](https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090/3 "2023-10-17T18:18:22Z")

</div>

Thanks!! I will try later when I find the time. Just threw it out here meanwhile to see if someone had experienced something similar.

---

<div class="post-metadata">

### Author: ![Kruxigt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kruxigt/32/11694_2.png) [@Kruxigt](https://discourse.julialang.org/u/Kruxigt)
#### Post date: [October 17, 2023, 10:18pm UTC](https://discourse.julialang.org/t/wrong-supertype-for-compiled-sysimage/105090/4 "2023-10-17T22:18:29Z")

</div>

OK So now I have ran a bit more experiments and this is where I stand now.

I have the two following functions in my package

```julia
function test_supertype(t::Type)
    return supertype(t)
end

function test_supertype_math(t::Type{T}) where T <: Number
    return supertype(t)
end

```

If I then compile a sysimage from the package with the arguments `compile=all --strip-ir`  
I get  
`test_supertype(Int64) -> Signed (correct)`  
`test_supertype_math(Int64) -> Integer (incorrect)`  
So it seems like for some reason if the `--strip-ir` command is included then the second function is broken and actually returns `supertype(supertype(t))`

Julia 1.10 Beta 3  
PackageCompiler v2.1.5
