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

Doctest failures on julia 0.6 related to world age counter #398

Closed
ajkeller34 opened this issue Dec 31, 2016 · 3 comments
Closed

Doctest failures on julia 0.6 related to world age counter #398

ajkeller34 opened this issue Dec 31, 2016 · 3 comments

Comments

@ajkeller34
Copy link

I'm encountering a doctest failure on Julia 0.6.0-dev (built yesterday) which is related to the newly-implemented world age counter (JuliaLang/julia#17057). I've made a minimal example in a mockup package that I'll call DocumenterTest. Here's the code:

module DocumenterTest

immutable TestType{T} end

function _show end
Base.show(io::IO, t::TestType) = _show(io, t)

macro define_show_and_make_object(x, y)
    z = Expr(:quote, x)
    esc(quote
        DocumenterTest._show(io::IO, t::DocumenterTest.TestType{$z}) = print(io, $y)
        const $x = DocumenterTest.TestType{$z}()
    end)
end

end # module

At the REPL you may try using the macro, which defines a method for show and makes an object:

julia> DocumenterTest.@define_show_and_make_object q "abcd"
abcd

julia> q
abcd

julia> DocumenterTest.TestType{:q}()
abcd

Now suppose we open a new Julia session. If we try to run Documenter with the following markdown file, the doctest will error (pretend I used three backticks, I'm not sure how to get the formatting right here):

``@meta
DocTestSetup = quote
    using DocumenterTest
end
``

``jldoctest
julia> DocumenterTest.@define_show_and_make_object q "abcd"
abcd
``

The output from the doctest is the following error instead of "abcd":

MethodError: no method matching _show(::IOContext{Base.AbstractIOBuffer{Array{UInt8,1}}}, ::DocumenterTest.TestType{:q})
The applicable method may be too new: running in world age 20490, while current world is 20492.
Closest candidates are:
  _show(::IO, ::DocumenterTest.TestType{:q}) at /Users/ajkeller/.julia/v0.6/DocumenterTest/src/DocumenterTest.jl:12 (method too new to be called from this world context.)
@MichaelHatherly
Copy link
Member

If it's specific to show-related code then perhaps just needs something like

diff --git a/src/DocChecks.jl b/src/DocChecks.jl
index 7d229d6..5cb9674 100644
--- a/src/DocChecks.jl
+++ b/src/DocChecks.jl
@@ -271,7 +271,7 @@ end

 function result_to_string(buf, value)
     dis = text_display(buf)
-    value === nothing || display(dis, value)
+    value === nothing || eval(Expr(:call, display, dis, value))
     sanitise(buf)
 end

perhaps. Does that help at all?

@ajkeller34
Copy link
Author

Yes, that seems to solve both my test case and my problem-in-the-wild. Thank you!

MichaelHatherly added a commit to MichaelHatherly/Documenter.jl that referenced this issue Jan 1, 2017
MichaelHatherly added a commit to MichaelHatherly/Documenter.jl that referenced this issue Jan 1, 2017
@MichaelHatherly
Copy link
Member

Fix will be part of 0.8.9 to be tagged shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants