REPL crashes upon completion

Create a struct, then define eltype for it, (see docs for the Iteration interface). Type Col in the REPL and press the TAB key, and the REPL will crash.

This problem arises if eltype is defined. (full stacktrace). It occurs in Linux(WSL2) and Windows11.

Version

julia> versioninfo()
Julia Version 1.12.1
Commit ba1e628ee49 (2025-10-17 13:02 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 13th Gen Intel(R) Core(TM) i7-1355U
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, alderlake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 12 virtual cores)

MWE and Stacktrace (head)

julia> mutable struct Collatz
          n
       end

julia> Base.eltype(Collatz) = Int

julia> for c in ColUnhandled Task ERROR: TaskFailedException
Stacktrace:
 [1] #wait#582
   @ ./task.jl:363 [inlined]
 [2] wait
   @ ./task.jl:360 [inlined]
 [3] fetch
   @ ./task.jl:525 [inlined]
 [4] prompt!(term::Base.Terminals.TextTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
   @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2983
 [5] run_interface(terminal::Base.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
   @ REPL.LineEdit ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/LineEdit.jl:2849
 [6] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
   @ REPL ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:1663
 [7] (::REPL.var"#61#62"{REPL.LineEditREPL, REPL.REPLBackendRef})()
   @ REPL ~/.julia/juliaup/julia-1.12.1+0.x64.linux.gnu/share/julia/stdlib/v1.12/REPL/src/REPL.jl:650

    nested task error: MethodError: Cannot `convert` an object of type SubString{String} to an object of type Int64
    The function `convert` exists, but no method is defined for this combination of argument types.

You just redefined the catch-all Base.eltype(::Any) method

which breaks a lot of Julia, including the REPL (basically every object will now have an element type of Int, even though it in fact contains Strings, which probably is what broke completions).

The correct way to define a custom eltype method would be

julia> mutable struct Collatz
          n
       end

julia> Base.eltype(::Type{Collatz}) = Int

julia> eltype(Collatz(3))
Int64

Whether that matches your intention with e.g. Collatz("string") is another matter, as is defining the rest of the iteration interface.

2 Likes