Skip to content

Commit

Permalink
Fix is_doc_expr by constraining number of args (#539)
Browse files Browse the repository at this point in the history
Fix for #538
  • Loading branch information
mgkurtz authored Jul 24, 2022
1 parent 7fe78fa commit 75bc4fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ function is_doc_expr(@nospecialize(ex))
docsym = Symbol("@doc")
if isexpr(ex, :macrocall)
ex::Expr
length(ex.args) == 4 || return false
a = ex.args[1]
is_global_ref(a, Core, docsym) && return true
isa(a, Symbol) && a == docsym && return true
Expand Down
12 changes: 11 additions & 1 deletion test/toplevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ end
io = IOBuffer()
show(io, @doc(Main.DocStringTest))
@test occursin("Special", String(take!(io)))
# issue #538
@test !JuliaInterpreter.is_doc_expr(:(Core.@doc "string"))
ex = quote
@doc("no docstring")

sum
end
modexs = collect(ExprSplitter(Main, ex))
m, ex = first(modexs)
@test !JuliaInterpreter.is_doc_expr(ex.args[2])

@test !isdefined(Main, :JIInvisible)
collect(ExprSplitter(JIVisible, :(module JIInvisible f() = 1 end)))
Expand Down Expand Up @@ -561,4 +571,4 @@ end
@test JuliaInterpreter.finish!(Frame(mod, ex), true) === nothing
end
@test length(modexs) == 2
end
end

0 comments on commit 75bc4fb

Please sign in to comment.