-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
fix #27352, disallow print
/string
of nothing
#27829
Conversation
93b29d6
to
6ad9f2c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intended to make this comment visible 2 days ago, but apparently it got stuck in Github's review queue :(
@@ -557,6 +557,7 @@ function show(io::IO, tn::Core.TypeName) | |||
end | |||
|
|||
show(io::IO, ::Nothing) = print(io, "nothing") | |||
print(io::IO, ::Nothing) = throw(MethodError(print, (io, nothing))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think almost any other error type would be better. As it is, this will make us print:
“No method matching print(nothing). Did you mean print(nothing) instead?”
Currently anything that's `dump`ed that contains `nothing` will error, since there's no logic in place for handling `nothing` in `dump` after PR #27829.
Currently anything that's `dump`ed that contains `nothing` will error, since there's no logic in place for handling `nothing` in `dump` after PR #27829.
This is a breaking change to the beta; this should at very least be deprecated first. This changes makes every This also contradicts the documented behaviour of
By that definition, there doesn't seem to be any room for a case where |
What if the show fallback were to wrap its output in backticks or something to indicate that it was not just a plain string? That would mean that the printing of nothing would be sufficiently weird to avoid any chance of it accidentally being spliced into a command or something in a way that calls a command or opens a file called nothing. |
Currently anything that's `dump`ed that contains `nothing` will error, since there's no logic in place for handling `nothing` in `dump` after PR #27829.
I don't think that helps much, except in that it's much less likely for a filename with backticks to exist. Or we could handle this by only giving an error in backtick interpolation, instead of |
I had assumed that was the original plan. 👍 to that. |
fixes #27352