diff --git a/src/utils.jl b/src/utils.jl index fbba6ca..44a5037 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -129,6 +129,10 @@ function is_func_expr(@nospecialize(ex), meth::Method) isexpr(lastarg, :...) && return true continue end + if isexpr(arg, :...) # also test the other order of $ and ..., e.g., `c470($argnames...)` + lastarg = only(arg.args) + isexpr(lastarg, :$) && return true + end aname = get_argname(arg) aname === :_ && continue aname === marg || (aname === Symbol("#unused#") && marg === Symbol("")) || return false diff --git a/test/runtests.jl b/test/runtests.jl index 84105a5..eb2657c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -210,7 +210,9 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j src, line = definition(String, m) @test occursin("x + y + z", src) @test line == 94 - + src, line = definition(String, only(methods(c470))) + @test occursin("\$argnames", src) + @test line == 137 # unnamed arguments m = which(unnamedarg, (Type{String}, Any)) diff --git a/test/script.jl b/test/script.jl index 9d4a2ba..a46de79 100644 --- a/test/script.jl +++ b/test/script.jl @@ -128,4 +128,14 @@ struct Invert end # USERID gets parsed into a Symbol struct symbol_struct2 USERID -end; '\n' ;symbol_function(x) = x \ No newline at end of file +end; '\n' ;symbol_function(x) = x + +# https://github.com/JuliaDebug/Cthulhu.jl/issues/470 +# (arguments with evaled-names) +let argnames = :args + eval(quote + function c470($argnames...) + return $argnames + end + end) +end