Created
February 28, 2024 19:21
-
-
Save mbauman/60f311851c930ff6a094096ba4b95359 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
julia> using StructArrays | |
julia> begin | |
g(x::StructArray{<:Tuple{String}}) = nothing | |
g(x::StructArray{<:Tuple{Integer}}) = nothing | |
function f(x) | |
# ok, yes, this line is fairly contrived, but this is a short-hand for | |
# building a partial type-instability -- something that happens frequently | |
z1 = Core.compilerbarrier(:type, x)::StructArray{<:Tuple{Nothing}} | |
z2 = g(z1) | |
nothing === z2, z2 | |
end | |
end; | |
julia> f(StructArray((Union{}[],))) | |
ERROR: MethodError: g(::StructVector{Tuple{Union{}}, Tuple{Vector{Union{}}}, Int64}) is ambiguous. | |
Candidates: | |
g(x::StructArray{<:Tuple{String}}) | |
@ Main REPL[2]:2 | |
g(x::StructArray{<:Tuple{Integer}}) | |
@ Main REPL[2]:3 | |
Possible fix, define | |
g(::StructArray{Union{}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment