You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #35094 I initially used jldoctest for the demonstration, but I got several errors that, in the end, I gave up trying to fix. I suspect this is mostly because it created a new module. Suspiciously, the modules chapter of the manual is entirely free of doctests.
The fundamental error is
```jldoctest│ julia> module Hinter│ │ only_int(x::Int) = 1│ any_number(x::Number) = 2│ │ function __init__()│ register_error_hint(MethodError) do io, exc, argtypes, kwargs│ if exc.f == only_int│ print(io, "\nDid you mean to call ")│ printstyled(io, "`any_number`?", color=:light_magenta)│ end│ end│ end│ │ end│ Main.Hinter│ │ julia> Hinter.only_int(1.0)│ ERROR: MethodError: no method matching only_int(::Float64)│ Did you mean to call `any_number`?│ Closest candidates are:│ [...]│ ```
│
│ Subexpression:
│
│ module Hinter
│
│ Evaluated output:
│
│ ERROR: syntax: incomplete: premature end of input
│ Stacktrace:
│ [1] top-level scope at none:180
│
│ Expected output:
│
│
│ only_int(x::Int) =1
│ any_number(x::Number) =2
│
│ function__init__()
│ register_error_hint(MethodError) do io, exc, argtypes, kwargs
│ if exc.f == only_int
│ print(io, "\nDid you mean to call ")
│ printstyled(io, "`any_number`?", color=:light_magenta)
│ end
│ end
│ end
│
│ end
│ Main.Hinter
│
│ diff =
│ Warning: Diff output requires color.
│
│ only_int(x::Int) =1
│ any_number(x::Number) =2
│
│ function__init__()
│ register_error_hint(MethodError) do io, exc, argtypes, kwargs
│ if exc.f == only_int
│ print(io, "\nDid you mean to call ")
│ printstyled(io, "`any_number`?", color=:light_magenta)
│ end
│ end
│ end
│
│ end
│ Main.HinterERROR: syntax: incomplete: premature end of input
│ Stacktrace:
│ [1] top-level scope at none:180
└ @ Documenter.DocTests ~/src/julia-master/doc/deps/packages/Documenter/HmOsT/src/DocTests.jl:369
┌ Error: doctest failure in errorshow.jl
The text was updated successfully, but these errors were encountered:
timholy
changed the title
Doctests for modules are troublesome (premature end of output)
Doctests for modules are troublesome (premature end of input)
Mar 15, 2020
Probably works if you write it with not empty lines, i.e.
julia> module Hinter
only_int(x::Int) = 1
any_number(x::Number) = 2
function __init__()
register_error_hint(MethodError) do io, exc, argtypes, kwargs
if exc.f == only_int
print(io, "\nDid you mean to call ")
printstyled(io, "`any_number`?", color=:light_magenta)
end
end
end
end
In #35094 I initially used
jldoctest
for the demonstration, but I got several errors that, in the end, I gave up trying to fix. I suspect this is mostly because it created a new module. Suspiciously, the modules chapter of the manual is entirely free of doctests.The fundamental error is
The text was updated successfully, but these errors were encountered: