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

Fix dump in the presence of nothing #27991

Merged
merged 1 commit into from
Jul 9, 2018
Merged

Fix dump in the presence of nothing #27991

merged 1 commit into from
Jul 9, 2018

Conversation

ararslan
Copy link
Member

@ararslan ararslan commented Jul 8, 2018

Currently anything that's dumped that contains nothing will error, since there's no logic in place for handling nothing in dump after PR #27829, which removed print(::Nothing).

Before:

julia> dump(first(methods(sin)))
Method
  name: Symbol sin
  module: Module Base.MPFR
  file: Symbol mpfr.jl
  line: Int32 683
  sig: Tuple{typeof(sin),BigFloat} <: Any
  min_world: Int64 12691
  ambig: Nothing ERROR: ArgumentError: `nothing` should not be printed; use `show`, `repr`, or custom output instead.
Stacktrace:
 [1] print(::IOContext{Base.TTY}, ::Nothing) at ./show.jl:560
 [2] print(::IOContext{Base.TTY}, ::String, ::Nothing) at ./strings/io.jl:40
 [3] dump(::IOContext{Base.TTY}, ::Any, ::Int64, ::String) at ./show.jl:1611
 [4] dump(::IOContext{Base.TTY}, ::Any, ::Int64, ::String) at ./show.jl:1604
 [5] #dump#368 at ./show.jl:1688 [inlined]
 [6] (::getfield(Base, Symbol("#kw##dump")))(::NamedTuple{(:maxdepth,),Tuple{Int64}}, ::typeof(dump), ::IOContext{Base.TTY}, ::Method) at ./none:0
 [7] #dump#369(::Int64, ::Function, ::Method) at ./show.jl:1720
 [8] dump(::Method) at ./show.jl:1720
 [9] top-level scope at none:0

After:

julia> dump(first(methods(sin)))
Method
  name: Symbol sin
  module: Module Base.MPFR
  file: Symbol mpfr.jl
  line: Int32 683
  sig: Tuple{typeof(sin),BigFloat} <: Any
  min_world: Int64 12689
  ambig: Nothing nothing
  specializations: Nothing nothing
  sparam_syms: empty SimpleVector
  source: Array{UInt8}((579,)) UInt8[0x00, 0x03, 0x00, 0x00, 0x00, 0x23, 0x73, 0x65, 0x6c, 0x66  …  0xb7, 0xf6, 0x16, 0x01, 0xba, 0xf6, 0x00, 0x00, 0x10, 0x00]
  unspecialized: #undef
  generator: #undef
  roots: Array{Any}((3,))
    1: String "mpfr_sin"
    2: Ref{BigFloat} <: Any
    3: String "NaN result for non-NaN input."
  invokes: #undef
  nargs: Int32 2
  called: Int32 0
  nospecialize: Int32 0
  isva: Bool false
  pure: Bool false

@ararslan ararslan added kind:bugfix This change fixes an existing bug domain:display and printing Aesthetics and correctness of printed representations of objects. labels Jul 8, 2018
Copy link
Sponsor Member

@JeffBezanson JeffBezanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead, line 1611 should be changed to call show by default. show is more correct for displaying an arbitrary unknown value.

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.
@ararslan
Copy link
Member Author

ararslan commented Jul 8, 2018

Fixed.

@ararslan
Copy link
Member Author

ararslan commented Jul 9, 2018

FreeBSD and macOS failures are issues with Curl in the download test.

@ararslan ararslan merged commit 8d48f7b into master Jul 9, 2018
@ararslan ararslan deleted the aa/dump-nothing branch July 9, 2018 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:display and printing Aesthetics and correctness of printed representations of objects. kind:bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants