Skip to content

terminfo parser: extendedterminfo() results in conversion error for TERM=screen-256color #51190

@tkemmer

Description

@tkemmer

I just noticed that current Julia 1.11-dev's REPL throws a conversion error on startup for TERM=screen-256color (ncurses 6.4) on my Gentoo system:

ERROR: MethodError: Cannot `convert` an object of type 
  UInt32 to an object of type 
  Union{Bool, Int64, String}

Closest candidates are:
  convert(::Type{T}, !Matched::T) where T
   @ Base Base.jl:84

Stacktrace:
  [1] setindex!(h::Dict{Symbol, Union{Bool, Int64, String}}, v0::UInt32, key::Symbol)
    @ Base ./dict.jl:374
  [2] Dict{Symbol, Union{Bool, Int64, String}}(kv::Vector{Pair{Symbol}})
    @ Base ./dict.jl:84
  [3] extendedterminfo(data::IOStream; NumInt::Type{UInt32})
    @ Base ./terminfo.jl:145
  [4] read(data::IOStream, ::Type{Base.TermInfoRaw})
    @ Base ./terminfo.jl:110
  [5] #440
    @ Base ./io.jl:486 [inlined]
  [6] open(f::Base.var"#440#441"{Base.TermInfoRaw}, args::String; kwargs::@Kwargs{})
    @ Base ./io.jl:396
  [7] open
    @ Base ./io.jl:393 [inlined]
  [8] read
    @ Base ./io.jl:486 [inlined]
  [9] load_terminfo(term::String)
    @ Base ./terminfo.jl:241
 [10] (::Base.var"#1041#1043"{Bool, Symbol, Bool})(REPL::Module)
    @ Base ./client.jl:407
 [11] #invokelatest#2
    @ Base ./essentials.jl:895 [inlined]
 [12] invokelatest
    @ Base ./essentials.jl:892 [inlined]
 [13] run_main_repl(interactive::Bool, quiet::Bool, banner::Symbol, history_file::Bool, color_set::Bool)
    @ Base ./client.jl:405
 [14] main(ARGS::Any)
    @ REPL /usr/lib64/julia-latest/share/julia/stdlib/v1.11/REPL/src/REPL.jl:1522
 [15] _start()
    @ Base ./client.jl:552

This does not seem to be the same issue as #51110 but rather a problem with the way the return value of extendedterminfo() is constructed [1] (since #50797). The involved dictionary expects a value of type Union{Bool, Int, String} and tries to convert the elements of the numbers array (either UInt16 or UInt32, depending on the function's NumInt parameter) accordingly.

[1] https://github.com/JuliaLang/julia/blame/master/base/terminfo.jl#L145-L146

versioninfo()

Julia Version 1.11.0-DEV.405
Commit fc2f997303e (2023-09-05 08:57 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 8 × Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
  WORD_SIZE: 64
  LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

MWE

TERM=screen-256color julia

screen-256color.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions