Is this type-piracy, and is the resulting crash expected?

Hello,

In a temp session, if I import Base.∈ and extend it with

∈(A,Interval) = (minimum(Interval) <= A <= maximum(Interval))

attempting to tab-complete the line -1.0 \in causes the session to crash (versioninfo() and error message below the fold).

If I instead write a function with a generic but matching type (e.g. ∈(A::T, Interval::Tuple{T,T}) where {T}) the tab-complete works fine.

Certainly the error message could be more clear and ideally the session should not crash; my question is whether this is a form of type-piracy and so the crash should be anticipated, or if this is something more subtle?

versioninfo():

Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 32 × AMD Ryzen 9 7950X 16-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, znver3)
Threads: 1 default, 0 interactive, 1 GC (on 32 virtual cores)
Unhandled Task ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] reduce_empty(op::Base.BottomRF{typeof(min)}, ::Type{Union{}})
    @ Base ./reduce.jl:360
  [2] reduce_empty_iter(op::Base.BottomRF{typeof(min)}, itr::Tuple{}, ::Base.HasEltype)
    @ Base ./reduce.jl:384
  [3] reduce_empty_iter(op::Base.BottomRF{typeof(min)}, itr::Tuple{})
    @ Base ./reduce.jl:383
  [4] foldl_impl(op::Base.BottomRF{typeof(min)}, nt::Base._InitialValue, itr::Tuple{})
    @ Base ./reduce.jl:49
  [5] mapfoldl_impl(f::typeof(identity), op::typeof(min), nt::Base._InitialValue, itr::Tuple{})
    @ Base ./reduce.jl:44
  [6] mapfoldl(f::Function, op::Function, itr::Tuple{}; init::Base._InitialValue)
    @ Base ./reduce.jl:175
  [7] mapfoldl
    @ ./reduce.jl:175 [inlined]
  [8] mapreduce(f::Function, op::Function, itr::Tuple{})
    @ Base ./reduce.jl:307
  [9] minimum(a::Tuple{}; kw::@Kwargs{})
    @ Base ./reduce.jl:796
 [10] in(A::Char, Interval::Tuple{})
    @ Main ./REPL[7]:1
 [11] escape_string(io::IOBuffer, s::String, esc::Tuple{Char, Char}; keep::Tuple{})
    @ Base ./strings/io.jl:411
 [12] escape_string
    @ ./strings/io.jl:406 [inlined]
 [13] print_quoted
    @ ./strings/io.jl:440 [inlined]
 [14] show(io::IOBuffer, s::String)
    @ Base ./strings/io.jl:197
 [15] sprint(f::Function, args::String; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
 [16] repr(x::String; context::Nothing)
    @ Base ./strings/io.jl:286
 [17] show_sym(io::IOContext{IOBuffer}, sym::Symbol; allow_macroname::Bool)
    @ Base ./show.jl:1747
 [18] show_sym
    @ ./show.jl:1740 [inlined]
 [19] show_type_name(io::IOContext{IOBuffer}, tn::Core.TypeName)
    @ Base ./show.jl:1054
 [20] _show_type(io::IOContext{IOBuffer}, x::Type)
    @ Base ./show.jl:956
 [21] show(io::IOContext{IOBuffer}, x::Type)
    @ Base ./show.jl:953
 [22] print(io::IOContext{IOBuffer}, x::Type)
    @ Base ./strings/io.jl:35
 [23] print(::IOContext{IOBuffer}, ::String, ::Type, ::Vararg{Any})
    @ Base ./strings/io.jl:46
 [24] with_output_color(::Function, ::Symbol, ::IOContext{IOBuffer}, ::String, ::Vararg{Any}; bold::Bool, italic::Bool, underline::Bool, blink::Bool, reverse::Bool, hidden::Bool)
    @ Base ./util.jl:78
 [25] printstyled(::IOContext{IOBuffer}, ::String, ::Vararg{Any}; bold::Bool, italic::Bool, underline::Bool, blink::Bool, reverse::Bool, hidden::Bool, color::Symbol)
    @ Base ./util.jl:141
 [26] print_within_stacktrace(::IOContext{IOBuffer}, ::String, ::Vararg{Any}; color::Symbol, bold::Bool)
    @ Base ./show.jl:2501
 [27] print_within_stacktrace
    @ ./show.jl:2499 [inlined]
 [28] show_signature_function(io::IOContext{IOBuffer}, ft::Any, demangle::Bool, fargname::String, html::Bool, qualified::Bool)
    @ Base ./show.jl:2493
 [29] show_tuple_as_call(out::IOContext{IOBuffer}, name::Symbol, sig::Type; demangle::Bool, kwargs::Nothing, argnames::Vector{Symbol}, qualified::Bool, hasfirst::Bool)
    @ Base ./show.jl:2526
 [30] show_tuple_as_call
    @ ./show.jl:2507 [inlined]
 [31] show_spec_sig(io::IOContext{IOBuffer}, m::Method, sig::Type)
    @ Base.StackTraces ./stacktraces.jl:265
 [32] show_spec_linfo(io::IOContext{IOBuffer}, frame::Base.StackTraces.StackFrame)
    @ Base.StackTraces ./stacktraces.jl:232
 [33] print_stackframe(io::IOContext{IOBuffer}, i::Int64, frame::Base.StackTraces.StackFrame, n::Int64, ndigits_max::Int64, modulecolor::Symbol)
    @ Base ./errorshow.jl:742
 [34] print_stackframe(io::IOContext{IOBuffer}, i::Int64, frame::Base.StackTraces.StackFrame, n::Int64, ndigits_max::Int64, modulecolordict::IdDict{Module, Symbol}, modulecolorcycler::Base.Iterators.Stateful{Base.Iterators.Cycle{Vector{Symbol}}, Union{Nothing, Tuple{Symbol, Int64}}, Int64})
    @ Base ./errorshow.jl:706
 [35] show_full_backtrace(io::IOContext{IOBuffer}, trace::Vector{Any}; print_linebreaks::Bool)
    @ Base ./errorshow.jl:605
 [36] show_full_backtrace
    @ ./errorshow.jl:598 [inlined]
 [37] show_backtrace(io::IOContext{IOBuffer}, t::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}})
    @ Base ./errorshow.jl:802
 [38] showerror(io::IOContext{IOBuffer}, ex::MethodError, bt::Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}; backtrace::Bool)
    @ Base ./errorshow.jl:97
 [39] showerror
    @ ./errorshow.jl:93 [inlined]
 [40] showvalue(io::IOContext{IOBuffer}, e::Tuple{MethodError, Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}})
    @ Logging ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/Logging/src/ConsoleLogger.jl:56
 [41] handle_message(logger::Logging.ConsoleLogger, level::Base.CoreLogging.LogLevel, message::Any, _module::Any, group::Any, id::Any, filepath::Any, line::Any; kwargs...)
    @ Logging ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/Logging/src/ConsoleLogger.jl:134
 [42] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::@Kwargs{exception::Tuple{MethodError, Vector{Union{Ptr{Nothing}, Base.InterpreterIP}}}})
    @ Base ./essentials.jl:894
 [43] macro expansion
    @ ./logging.jl:377 [inlined]
 [44] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2751
 [45] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2651
 [46] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
 [47] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386

caused by: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
Stacktrace:
  [1] reduce_empty(op::Base.BottomRF{typeof(min)}, ::Type{Union{}})
    @ Base ./reduce.jl:360
  [2] reduce_empty_iter(op::Base.BottomRF{typeof(min)}, itr::Tuple{}, ::Base.HasEltype)
    @ Base ./reduce.jl:384
  [3] reduce_empty_iter(op::Base.BottomRF{typeof(min)}, itr::Tuple{})
    @ Base ./reduce.jl:383
  [4] foldl_impl(op::Base.BottomRF{typeof(min)}, nt::Base._InitialValue, itr::Tuple{})
    @ Base ./reduce.jl:49
  [5] mapfoldl_impl(f::typeof(identity), op::typeof(min), nt::Base._InitialValue, itr::Tuple{})
    @ Base ./reduce.jl:44
  [6] mapfoldl(f::Function, op::Function, itr::Tuple{}; init::Base._InitialValue)
    @ Base ./reduce.jl:175
  [7] mapfoldl
    @ ./reduce.jl:175 [inlined]
  [8] mapreduce(f::Function, op::Function, itr::Tuple{})
    @ Base ./reduce.jl:307
  [9] minimum(a::Tuple{}; kw::@Kwargs{})
    @ Base ./reduce.jl:796
 [10] in(A::Char, Interval::Tuple{})
    @ Main ./REPL[7]:1
 [11] escape_string(io::IOBuffer, s::String, esc::Tuple{Char, Char}; keep::Tuple{})
    @ Base ./strings/io.jl:411
 [12] escape_string
    @ ./strings/io.jl:406 [inlined]
 [13] print_quoted
    @ ./strings/io.jl:440 [inlined]
 [14] show(io::IOBuffer, s::String)
    @ Base ./strings/io.jl:197
 [15] sprint(f::Function, args::String; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
 [16] repr(x::String; context::Nothing)
    @ Base ./strings/io.jl:286
 [17] repr
    @ ./strings/io.jl:286 [inlined]
 [18] show_sym(io::IOBuffer, sym::Symbol; allow_macroname::Bool)
    @ Base ./show.jl:1747
 [19] show_sym
    @ ./show.jl:1740 [inlined]
 [20] (::REPL.REPLCompletions.var"#3#8")(io::IOBuffer, s::Symbol)
    @ REPL.REPLCompletions ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:141
 [21] sprint(f::Function, args::Symbol; context::Nothing, sizehint::Int64)
    @ Base ./strings/io.jl:114
 [22] sprint
    @ ./strings/io.jl:107 [inlined]
 [23] #2
    @ ./none:0 [inlined]
 [24] iterate
    @ ./generator.jl:47 [inlined]
 [25] _collect(::Type{String}, itr::Base.Generator{Base.Iterators.Filter{REPL.REPLCompletions.var"#4#9"{String}, Vector{Symbol}}, REPL.REPLCompletions.var"#2#7"}, isz::Base.SizeUnknown)
    @ Base ./array.jl:702
 [26] collect
    @ ./array.jl:694 [inlined]
 [27] filtered_mod_names(ffunc::Function, mod::Module, name::String, all::Bool, imported::Bool)
    @ REPL.REPLCompletions ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:141
 [28] filtered_mod_names
    @ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:138 [inlined]
 [29] complete_symbol(ex::Any, name::String, ffunc::Any, context_module::Module)
    @ REPL.REPLCompletions ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:185
 [30] complete_identifiers!(suggestions::Vector{REPL.REPLCompletions.Completion}, ffunc::Any, context_module::Module, string::String, name::String, pos::Int64, dotpos::Int64, startpos::Int64; comp_keywords::Bool)
    @ REPL.REPLCompletions ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:1081
 [31] complete_identifiers!
    @ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:983 [inlined]
 [32] completions(string::String, pos::Int64, context_module::Module, shift::Bool)
    @ REPL.REPLCompletions ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPLCompletions.jl:1299
 [33] complete_line(c::REPL.REPLCompletionProvider, s::REPL.LineEdit.PromptState, mod::Module)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:545
 [34] complete_line(s::REPL.LineEdit.PromptState, repeats::Int64, mod::Module)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:376
 [35] complete_line(s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:367
 [36] edit_tab(s::REPL.LineEdit.MIState, jump_spaces::Bool, delete_trailing::Bool)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2320
 [37] edit_tab
    @ ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2320 [inlined]
 [38] (::REPL.LineEdit.var"#114#170")(::REPL.LineEdit.MIState, ::Any, ::Vararg{Any})
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2366
 [39] #invokelatest#2
    @ ./essentials.jl:892 [inlined]
 [40] invokelatest
    @ ./essentials.jl:889 [inlined]
 [41] (::REPL.LineEdit.var"#27#28"{REPL.LineEdit.var"#114#170", String})(s::Any, p::Any)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:1612
 [42] prompt!(term::REPL.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2749
 [43] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/LineEdit.jl:2651
 [44] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:1312
 [45] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:386
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:931
  [2] wait()
    @ Base ./task.jl:995
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base ./channels.jl:477
  [6] take!
    @ ./channels.jl:471 [inlined]
  [7] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:241
  [8] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:231
  [9] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:389
 [10] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL ~/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/share/julia/stdlib/v1.10/REPL/src/REPL.jl:375
 [11] fatal: error thrown and no exception handler available.
MethodError(f=Base.reduce_empty, args=(typeof(Base.min)(), Core.TypeofBottom()), world=0x0000000000007ae2)
jl_method_error_bare at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2208
jl_method_error at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2226
jl_lookup_generic_ at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3058 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3073
reduce_empty at ./reduce.jl:360
reduce_empty_iter at ./reduce.jl:384
reduce_empty_iter at ./reduce.jl:383
foldl_impl at ./reduce.jl:49
mapfoldl_impl at ./reduce.jl:44
unknown function (ip: 0x7b0bb0306af2)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#mapfoldl#298 at ./reduce.jl:175
mapfoldl at ./reduce.jl:175 [inlined]
#mapreduce#302 at ./reduce.jl:307 [inlined]
mapreduce at ./reduce.jl:307
#minimum#313 at ./reduce.jl:796
minimum at ./reduce.jl:796
in at ./REPL[7]:1
#escape_string#505 at ./strings/io.jl:411
escape_string at ./strings/io.jl:406 [inlined]
print_quoted at ./strings/io.jl:440 [inlined]
show at ./strings/io.jl:197
unknown function (ip: 0x7b0bb0347109)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
#sprint#501 at ./strings/io.jl:114
sprint at ./strings/io.jl:107
#repr#504 at ./strings/io.jl:286
repr at ./strings/io.jl:286
#show_sym#549 at ./show.jl:1747
show_sym at ./show.jl:1740 [inlined]
show_type_name at ./show.jl:1054
show_datatype at ./show.jl:1129
show_datatype at ./show.jl:1077 [inlined]
_show_type at ./show.jl:961
show at ./show.jl:953
print at ./strings/io.jl:35
unknown function (ip: 0x7b0bb03613f9)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
print at ./strings/io.jl:46
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
do_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:768
#with_output_color#994 at ./util.jl:78
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
do_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:768
with_output_color at ./util.jl:73
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
do_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:768
#printstyled#995 at ./util.jl:141
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
do_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:768
printstyled at ./util.jl:141
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
do_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:768
#print_within_stacktrace#557 at ./show.jl:2501
print_within_stacktrace at ./show.jl:2499 [inlined]
show_signature_function at ./show.jl:2493
#show_tuple_as_call#558 at ./show.jl:2526
show_tuple_as_call at ./show.jl:2507 [inlined]
show_spec_sig at ./stacktraces.jl:265
show_spec_linfo at ./stacktraces.jl:232
print_stackframe at ./errorshow.jl:742
print_stackframe at ./errorshow.jl:706
#show_full_backtrace#942 at ./errorshow.jl:605
show_full_backtrace at ./errorshow.jl:598 [inlined]
show_backtrace at ./errorshow.jl:802
#showerror#666 at ./task.jl:83
showerror at ./task.jl:80
unknown function (ip: 0x7b0bb03a00a5)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
show_exception_stack at ./errorshow.jl:975
display_error at ./client.jl:111
unknown function (ip: 0x7b0bb038c009)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
display_error at ./client.jl:114
unknown function (ip: 0x7b0bb038b845)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
jl_f__call_latest at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/builtins.c:812
#invokelatest#2 at ./essentials.jl:892 [inlined]
invokelatest at ./essentials.jl:889 [inlined]
_start at ./client.jl:554
jfptr__start_82729.1 at /home/chris/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:2895 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/gf.c:3077
jl_apply at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/julia.h:1982 [inlined]
true_main at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/jlapi.c:582
jl_repl_entrypoint at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/src/jlapi.c:731
main at /cache/build/builder-amdci4-0/julialang/julia-release-1-dot-10/cli/loader_exe.c:58
unknown function (ip: 0x7b0bb0a2a1c9)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x4010b8)

Type piracy happens if you don’t own the function or any of the argument types.

In this case you don’t own the function (you import Base’s ) and you don’t own any of the types of the arguments (Any and Any) so yes this is type piracy.

This is also type piracy with the same argumentation (you don’t own or any of Any and Tuple{Any, Any}).

The “punishment” for piracy is pretty unpredictable and depends on if any other code happen to hit your pirated method etc.

1 Like

A typical remedy here is to simply not overload Base.∈. You can still create your own MyModule.∈ and it will not conflict.

Another remedy would be to define your own Interval type and define Base.∈(::Any, ::Interval). Since you would own Interval, this would not be piracy and would not cause conflicts. More simply, packages like Intervals.jl appear to already provide interval types you could use.

1 Like