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)
Amusing. I think we should revert that change and only make interpolating nothing
into Cmd
objects an error since that was the original motivating case.
Every time this comes up and it is fixed, it seems the end result is an improvement over the previous situation though. For example, using show
correctly here would give invalid index: "foo" of type String
in the case that didn't error, which is nicer.
Agreed; this should be using show/repr for the value anyway.
Most helpful comment
Amusing. I think we should revert that change and only make interpolating
nothing
intoCmd
objects an error since that was the original motivating case.