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

Limit nothing interpolation error to AbstractCmd subtypes #30008

Closed
omus opened this issue Nov 12, 2018 · 6 comments
Closed

Limit nothing interpolation error to AbstractCmd subtypes #30008

omus opened this issue Nov 12, 2018 · 6 comments
Labels
display and printing Aesthetics and correctness of printed representations of objects. error handling Handling of exceptions by Julia or the user

Comments

@omus
Copy link
Member

omus commented Nov 12, 2018

The introduction of disallowing print/string with nothing (#27829) has introduced some headaches. From a recent #gripes session:

Mike Innes [2018-11-07 07:50]

julia> xs = [1, 2, 3]

julia> xs[nothing]
ERROR: ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output > instead.

Simon Danisch [08:32]
I'm getting so sick of nothing should not be printed errors 😄 The worst is, they usually happen in the display stack, which has the bad habbit of removing stack traces

Eric Davies [10:43]
It feels like an evil wizard is like "haha! you've fallen into my 'printing nothing' trap!"
And it causes so many special cases to be written in Base and in user code, all because special > casing Cmd interpolation was too hard to do in the very short period of time before release.

Stefan Karpinski [10:46]
I think it would be fine to limit the nothing error to splicing nothing into command objects

Stefan Karpinski [10:46]
if someone wants to make a PR for that

@omus omus added the display and printing Aesthetics and correctness of printed representations of objects. label Nov 12, 2018
@JeffBezanson
Copy link
Member

I think this is actually a bug in the error throwing code, which should be using show/repr instead of interpolation. For example:

julia> xs["my horse is"]
ERROR: ArgumentError: invalid index: my horse is of type String

@JeffBezanson JeffBezanson added the error handling Handling of exceptions by Julia or the user label Nov 12, 2018
@omus
Copy link
Member Author

omus commented Nov 12, 2018

I've also found this to be an annoyance with the change:

julia> x = nothing

julia> @error "Found unexpected value: $x"
┌ Error: Exception while generating log record in module Main at REPL[2]:1
│   exception =
│    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(::String, ::Nothing) at ./strings/io.jl:155
│     [4] top-level scope at logging.jl:321
│     [5] eval(::Module, ::Any) at ./boot.jl:319
│     [6] eval_user_input(::Any, ::REPL.REPLBackend) at /Users/omus/Development/Julia/1.0/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:85
│     [7] macro expansion at /Users/omus/Development/Julia/1.0/usr/share/julia/stdlib/v1.0/REPL/src/REPL.jl:117 [inlined]
│     [8] (::getfield(REPL, Symbol("##28#29")){REPL.REPLBackend})() at ./task.jl:259
└ @ Main REPL[2]:1

@StefanKarpinski
Copy link
Member

I agree, let's just restrict the error to splicing nothing into command objects.

@KristofferC
Copy link
Member

It seems like most of the time this issue comes up it is actually a bug that is being discovered.

@nickrobinson251
Copy link
Contributor

#32148

@omus
Copy link
Member Author

omus commented May 4, 2020

Thanks for the reminder. This issue has been resolved. At least all of the original gripes.

@omus omus closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

No branches or pull requests

5 participants