This is an MWE simplified from some code that tries to implement *
for a type and AbstractString
s. In this MWE, the intention is to return a Foo
whenever any argument is a Foo
.
Is this a bug, or user error? I think that the *
method should be more specific than the *(s1::Union{AbstractChar, AbstractString}, ss::Union{AbstractChar, AbstractString}...)
in Base
, so I am not sure why it is causing a problem.
julia> VERSION
v"1.9.3-DEV.0"
julia> struct Foo end
julia> Base.:(*)(::Foo, ::AbstractString...) = Foo()
julia> Base.:(*)(::AbstractString, ::Union{AbstractString,Foo}...) = Foo()
fatal: error thrown and no exception handler available.
MethodError(f=Base.:(*), args=("", "", "", "", "", ""), world=0x00000000000082c3)
jl_method_error_bare at /home/tamas/src/julia-1.9/src/gf.c:2076
jl_method_error at /home/tamas/src/julia-1.9/src/gf.c:2094
jl_lookup_generic_ at /home/tamas/src/julia-1.9/src/gf.c:2921 [inlined]
ijl_apply_generic at /home/tamas/src/julia-1.9/src/gf.c:2936
#with_output_color#962 at ./util.jl:87
with_output_color at ./util.jl:71 [inlined]
#printstyled#963 at ./util.jl:130 [inlined]
printstyled at ./util.jl:130
unknown function (ip: 0x7fb17932841d)
display_error at ./client.jl:110
unknown function (ip: 0x7fb179327b56)
display_error at ./client.jl:114
unknown function (ip: 0x7fb179327922)
jl_apply at /home/tamas/src/julia-1.9/src/julia.h:1879 [inlined]
jl_f__call_latest at /home/tamas/src/julia-1.9/src/builtins.c:774
#invokelatest#2 at ./essentials.jl:816 [inlined]
invokelatest at ./essentials.jl:813 [inlined]
_start at ./client.jl:524
jfptr__start_43091 at /home/tamas/src/julia-1.9/usr/lib/julia/sys.so (unknown line)
jl_apply at /home/tamas/src/julia-1.9/src/julia.h:1879 [inlined]
true_main at /home/tamas/src/julia-1.9/src/jlapi.c:573
jl_repl_entrypoint at /home/tamas/src/julia-1.9/src/jlapi.c:717
main at julia (unknown line)
unknown function (ip: 0x7fb1936daa8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at julia (unknown line)