Skip to content

vec[nothing] fails to print its error message #30633

Closed
@jamii

Description

@jamii

Expected:

julia> [1]["foo"]
ERROR: ArgumentError: invalid index: foo of type String
Stacktrace:
 [1] to_index(::String) at ./indices.jl:266
 [2] to_index(::Array{Int64,1}, ::String) at ./indices.jl:247
 [3] to_indices at ./indices.jl:294 [inlined]
 [4] to_indices at ./indices.jl:291 [inlined]
 [5] getindex(::Array{Int64,1}, ::String) at ./abstractarray.jl:905
 [6] top-level scope at none:0

Actual:

julia> [1][nothing]
ERROR: ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.
Stacktrace:
 [1] print(::Base.GenericIOBuffer{Array{UInt8,1}}, ::Nothing) at ./show.jl:566
 [2] print_to_string(::String, ::Vararg{Any,N} where N) at ./strings/io.jl:122
 [3] string at ./strings/io.jl:155 [inlined]
 [4] to_index(::Nothing) at ./indices.jl:266
 [5] to_index(::Array{Int64,1}, ::Nothing) at ./indices.jl:247
 [6] to_indices at ./indices.jl:294 [inlined]
 [7] to_indices at ./indices.jl:291 [inlined]
 [8] getindex(::Array{Int64,1}, ::Nothing) at ./abstractarray.jl:905
 [9] top-level scope at none:0

julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E3-1505M v5 @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

Metadata

Metadata

Assignees

No one assigned

    Labels

    error handlingHandling of exceptions by Julia or the usergood first issueIndicates a good issue for first-time contributors to Julia

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions