Skip to content

Commit c4c38d1

Browse files
Return error from at-doc if macroexpand fails.
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.
1 parent fca750e commit c4c38d1

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

base/docs/Docs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ function docm(meta, def, define = true)
541541
isvar(def′) ? objdoc(meta, def′) :
542542
isexpr(def′, :tuple) ? multidoc(meta, def′.args) :
543543
__doc__!(meta, def′) ? esc(def′) :
544+
isexpr(def′, :error) ? esc(def′) :
544545

545546
# All other expressions are undocumentable and should be handled on a case-by-case basis
546547
# with `@__doc__`. Unbound string literals are also undocumentable since they cannot be

test/docs.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,9 @@ end
471471
@test docstrings_equal(Docs.doc(I13068.A.foo, Tuple{Float64}), doc"foo from B")
472472
@test Docs.doc(I13068.A.foo, Tuple{Char}) === nothing
473473

474+
# Issue #13905.
475+
@test macroexpand(:(@doc "" f() = @x)) == Expr(:error, UndefVarError(symbol("@x")))
476+
474477
# Undocumented DataType Summaries.
475478

476479
module Undocumented

0 commit comments

Comments
 (0)