Skip to content

Commit 75bc4fb

Browse files
authored
Fix is_doc_expr by constraining number of args (#539)
Fix for #538
1 parent 7fe78fa commit 75bc4fb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ function is_doc_expr(@nospecialize(ex))
226226
docsym = Symbol("@doc")
227227
if isexpr(ex, :macrocall)
228228
ex::Expr
229+
length(ex.args) == 4 || return false
229230
a = ex.args[1]
230231
is_global_ref(a, Core, docsym) && return true
231232
isa(a, Symbol) && a == docsym && return true

test/toplevel.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ end
3636
io = IOBuffer()
3737
show(io, @doc(Main.DocStringTest))
3838
@test occursin("Special", String(take!(io)))
39+
# issue #538
40+
@test !JuliaInterpreter.is_doc_expr(:(Core.@doc "string"))
41+
ex = quote
42+
@doc("no docstring")
43+
44+
sum
45+
end
46+
modexs = collect(ExprSplitter(Main, ex))
47+
m, ex = first(modexs)
48+
@test !JuliaInterpreter.is_doc_expr(ex.args[2])
3949

4050
@test !isdefined(Main, :JIInvisible)
4151
collect(ExprSplitter(JIVisible, :(module JIInvisible f() = 1 end)))
@@ -561,4 +571,4 @@ end
561571
@test JuliaInterpreter.finish!(Frame(mod, ex), true) === nothing
562572
end
563573
@test length(modexs) == 2
564-
end
574+
end

0 commit comments

Comments
 (0)