Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
tkemmer opened this issue Sep 5, 2023 · 0 comments · Fixed by #51195 or #51198
Closed
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@tkemmer
Copy link

tkemmer commented Sep 5, 2023

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

vtjnash pushed a commit that referenced this issue Sep 5, 2023
Before, in the extendedterminfo function in terminfo.jl, if the numbers
array was nonempty, the function would fail as a `UInt32` cannot be
implicitly converted to the output `Int` type. Do this conversion
explicitly.

Closes #51190
@brenhinkeller brenhinkeller added the bug Indicates an unexpected problem or unintended behavior label Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
2 participants