Skip to content

Commit f32b803

Browse files
authored
Check nargs when extracting doc expressions (#221)
Ref JuliaLang/julia#31470 (comment)
1 parent fc15ae8 commit f32b803

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/construct.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ function split_expressions!(modexs, docexprs, lex::Expr, mod::Module, ex::Expr;
411411
end
412412
end
413413
split_expressions!(modexs, docexprs, lex, newmod, ex.args[3]; extract_docexprs=extract_docexprs, filename=filename)
414-
elseif extract_docexprs && is_doc_expr(ex)
414+
elseif extract_docexprs && is_doc_expr(ex) && length(ex.args) >= 4
415415
docexs = get(docexprs, mod, nothing)
416416
if docexs === nothing
417417
docexs = docexprs[mod] = Expr[]

test/toplevel.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ end
1616
end
1717
@test JuliaInterpreter.is_doc_expr(ex.args[2])
1818
@test !JuliaInterpreter.is_doc_expr(:(1+1))
19+
ex = :(@doc doc"""
20+
bla
21+
""")
22+
modexs, docexs = JuliaInterpreter.split_expressions(Main, ex; extract_docexprs=true)
23+
@test isempty(docexs)
1924

2025
@test JuliaInterpreter.prepare_thunk(Main, :(export foo)) === nothing
2126
@test JuliaInterpreter.prepare_thunk(Base.Threads, :(global Condition)) === nothing

0 commit comments

Comments
 (0)