From 83ba91912cfa02f8f3ce6ab08acfbbf2e0095d2e Mon Sep 17 00:00:00 2001 From: Tim Holy Date: Thu, 10 Dec 2020 14:47:58 -0600 Subject: [PATCH] Do not return disconnected IdDict from Docs.meta Fixes #38819 Fixes https://github.com/timholy/Revise.jl/issues/583 --- base/docs/Docs.jl | 7 ++++++- test/docs.jl | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index da315cadf81b1..251a01c20ab4f 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -73,7 +73,12 @@ const modules = Module[] const META = gensym(:meta) const METAType = IdDict{Any,Any} -meta(m::Module) = isdefined(m, META) ? getfield(m, META)::METAType : METAType() +function meta(m::Module) + if !isdefined(m, META) + initmeta(m) + end + return getfield(m, META)::METAType +end function initmeta(m::Module) if !isdefined(m, META) diff --git a/test/docs.jl b/test/docs.jl index c1c79fd9d53f4..465de47f026ad 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -73,6 +73,11 @@ end @test docstrings_equal(@doc(ModuleMacroDoc), doc"I am a module") @test docstrings_equal(@doc(ModuleMacroDoc.@m), doc"I am a macro") +# issue #38819 + +module NoDocStrings end +@test meta(NoDocStrings) === getfield(NoDocStrings, Base.Docs.META) + # General tests for docstrings. const LINE_NUMBER = @__LINE__() + 1