-
Notifications
You must be signed in to change notification settings - Fork 7
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
Duplicated error messages during doctests #42
Comments
It looks like the docstring gets attached to the simulator, and then for some reason Documenter.jl also tests that docstring even though it isn't included in the manual. Then, the function name isn't displayed in the error and the line numbers match, so it's difficult to tell what's going on. julia> @macroexpand @stable begin
"""
```jldoctest
julia> f()
```
"""
f() = 1
end
quote
#= REPL[6]:2 =#
begin
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:316 =#
begin
function var"##f_simulator#231"(; )
#= REPL[6]:7 =#
1
end
(Base.Docs.doc!)(Main, (Base.Docs.Binding)(Main, Symbol("##f_simulator#231")), (Base.Docs.docstr)((Core.svec)("```jldoctest\njulia> f()\n```\n"), (Dict{Symbol, Any})(:path => "REPL[6]", :linenumber => 2, :module => Main)), Union{Tuple{}})
end
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:317 =#
begin
$(Expr(:meta, :doc))
begin
function f(; )
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:298 =#
var"##f_return_type#232" = (Base).promote_op(var"##f_simulator#231", map(DispatchDoctor._Utils.specializing_typeof, ())...)
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:299 =#
if (DispatchDoctor._Utils.type_instability)(var"##f_return_type#232") && (!((DispatchDoctor._Interactions.ignore_function)(f)) && (DispatchDoctor._RuntimeChecks.checking_enabled)())
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:300 =#
throw((TypeInstabilityError)("`f`", "REPL[6]:7", (), (;), (DispatchDoctor._Stabilization._construct_pairs)((), ()), var"##f_return_type#232"))
end
#= /home/jakob/.julia/packages/DispatchDoctor/bx82n/src/stabilization.jl:303 =#
begin
#= REPL[6]:7 =#
1
end
end
(Base.Docs.doc!)(Main, (Base.Docs.Binding)(Main, :f), (Base.Docs.docstr)((Core.svec)("```jldoctest\njulia> f()\n```\n"), (Dict{Symbol, Any})(:path => "REPL[6]", :linenumber => 2, :module => Main)), Union{Tuple{}})
end
end
end
end |
Thanks for the report. Does this also occur if you set I wonder if we should try to strip the line numbers from the simulator function. As you can see, both This is the generated call: DispatchDoctor.jl/src/stabilization.jl Lines 315 to 318 in 7cf8c02
I wonder if the simulator function needs to be defined second for this to work? (And the regular function's symbol repeated at the end so it is the return value) |
Both EDIT: And also independently of each other too. eval(Base.remove_linenums!(@macroexpand @stable default_codegen_level = "min" begin
"""
```jldoctest
julia> i()
```
"""
i() = 4
end)) |
Hm... Very weird. I wonder if MacroTools.jl is adding that |
Worth looking into! Removing the simulator's const x = @macroexpand @stable begin
"""
```jldoctest
julia> j()
```
"""
j() = 5
end
pop!(x.args[2].args[2].args)
eval(x) |
Assuming As a test, switching the fallback behavior to |
Does putting |
The problem is that
|
I see, thanks. One thing I’m confused about is I though |
In a certain case, the error message from failed doctests of methods wrapped in
@stable
are duplicated. I've seen this before, but it was really challenging to debug and I couldn't pin down the source. Here is an example repository and CI job that demonstrate it. In the CI job, note that the error forf
andg
is displayed once but the error forh
is displayed twice.Works as expected
Duplicates error messages
The text was updated successfully, but these errors were encountered: