Skip to content

Commit

Permalink
Return error from at-doc if macroexpand fails.
Browse files Browse the repository at this point in the history
When `macroexpand` fails due to an undefined macro in the expression
return the resulting error rather than the more generic and misleading
"invalid doc expression..." error message.

Fixes JuliaLang#13905.
  • Loading branch information
MichaelHatherly committed Nov 7, 2015
1 parent fca750e commit c4c38d1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ function docm(meta, def, define = true)
isvar(def′) ? objdoc(meta, def′) :
isexpr(def′, :tuple) ? multidoc(meta, def′.args) :
__doc__!(meta, def′) ? esc(def′) :
isexpr(def′, :error) ? esc(def′) :

# All other expressions are undocumentable and should be handled on a case-by-case basis
# with `@__doc__`. Unbound string literals are also undocumentable since they cannot be
Expand Down
3 changes: 3 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,9 @@ end
@test docstrings_equal(Docs.doc(I13068.A.foo, Tuple{Float64}), doc"foo from B")
@test Docs.doc(I13068.A.foo, Tuple{Char}) === nothing

# Issue #13905.
@test macroexpand(:(@doc "" f() = @x)) == Expr(:error, UndefVarError(symbol("@x")))

# Undocumented DataType Summaries.

module Undocumented
Expand Down

0 comments on commit c4c38d1

Please sign in to comment.