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

Handle :error and :invalid expressions gracefully in REPL helpmode #30754

Merged
merged 1 commit into from
Jan 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ helpmode(line::AbstractString) = helpmode(stdout, line)

function _helpmode(io::IO, line::AbstractString)
line = strip(line)
x = Meta.parse(line, raise = false, depwarn = false)
expr =
if haskey(keywords, Symbol(line))
if haskey(keywords, Symbol(line)) || isexpr(x, :error) || isexpr(x, :invalid)
# Docs for keywords must be treated separately since trying to parse a single
# keyword such as `function` would throw a parse error due to the missing `end`.
Symbol(line)
else
x = Meta.parse(line, raise = false, depwarn = false)
# Retrieving docs for macros requires us to make a distinction between the text
# `@macroname` and `@macroname()`. These both parse the same, but are used by
# the docsystem to return different results. The first returns all documentation
Expand Down
6 changes: 6 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,12 @@ for (line, expr) in Pair[
@test Base.eval(REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing}
end

# PR 30754, Issues #22013, #24871, #26933, #29282, #29361, #30348
for line in ["′", "abstract", "type", "|=", ".="]
@test occursin("No documentation found.",
sprint(show, Base.eval(REPL._helpmode(IOBuffer(), line))::Union{Markdown.MD,Nothing}))
end

# PR #27562
fake_repl() do stdin_write, stdout_read, repl
repltask = @async begin
Expand Down