# REPL crashes upon completion

**URL:** <https://discourse.julialang.org/t/repl-crashes-upon-completion/134278>\
**Category:** General Usage\
**Tags:** crash\
**Created:** [December 2, 2025, 8:35am UTC](https://discourse.julialang.org/t/repl-crashes-upon-completion/134278 "2025-12-02T08:35:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![zweiglimmergneis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zweiglimmergneis/32/7892_2.png) [@zweiglimmergneis](https://discourse.julialang.org/u/zweiglimmergneis)\
**Post date:** [December 2, 2025, 8:35am UTC](https://discourse.julialang.org/t/repl-crashes-upon-completion/134278/1 "2025-12-02T08:35:28Z")

</div>

Create a struct, then define `eltype` for it, (see [docs](https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-iteration) 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](https://pastebin.com/GFZPUxdg)). It occurs in Linux(WSL2) and Windows11.

Version

```julia
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
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.

```

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [December 2, 2025, 9:31am UTC](https://discourse.julialang.org/t/repl-crashes-upon-completion/134278/2 "2025-12-02T09:31:50Z")

</div>

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

> <https://github.com/JuliaLang/julia/blob/master/base/abstractarray.jl#L245>

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 `String`s, which probably is what broke completions).

The correct way to define a custom `eltype` method would be

```julia-auto
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.
