Open
Description
openedon Sep 12, 2024
Minimal reproducer:
julia> struct A <: Integer end
julia> struct B <: Integer end
julia> Union{A,B}(1//2)
ERROR: MethodError: no method matching nameof(::Type{Union{A, B}})
The function `nameof` exists, but no method is defined for this combination of argument types.
Closest candidates are:
nameof(::Core.IntrinsicFunction)
@ Base reflection.jl:2369
nameof(::Module)
@ Base essentials.jl:401
nameof(::UnionAll)
@ Base reflection.jl:343
...
Stacktrace:
[1] Union{A, B}(x::Rational{Int64})
@ Base ./rational.jl:151
[2] top-level scope
@ REPL[3]:1
It's not valid to call nameof
on an arbitrary subtype of Integer
, because it may be an Union
:
Lines 149 to 152 in 945517b
It seems like this could be fixed by simply replacing the nameof
call with :convert
.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment