Skip to content

Commit b8b32b4

Browse files
authored
Fix handling of $argsnames... (#120)
Fixes JuliaDebug/Cthulhu.jl#470
1 parent 9db8d0e commit b8b32b4

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/utils.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ function is_func_expr(@nospecialize(ex), meth::Method)
129129
isexpr(lastarg, :...) && return true
130130
continue
131131
end
132+
if isexpr(arg, :...) # also test the other order of $ and ..., e.g., `c470($argnames...)`
133+
lastarg = only(arg.args)
134+
isexpr(lastarg, :$) && return true
135+
end
132136
aname = get_argname(arg)
133137
aname === :_ && continue
134138
aname === marg || (aname === Symbol("#unused#") && marg === Symbol("")) || return false

test/runtests.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,9 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
210210
src, line = definition(String, m)
211211
@test occursin("x + y + z", src)
212212
@test line == 94
213-
213+
src, line = definition(String, only(methods(c470)))
214+
@test occursin("\$argnames", src)
215+
@test line == 137
214216

215217
# unnamed arguments
216218
m = which(unnamedarg, (Type{String}, Any))

test/script.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,14 @@ struct Invert end
128128
# USERID gets parsed into a Symbol
129129
struct symbol_struct2
130130
USERID
131-
end; '\n' ;symbol_function(x) = x
131+
end; '\n' ;symbol_function(x) = x
132+
133+
# https://github.com/JuliaDebug/Cthulhu.jl/issues/470
134+
# (arguments with evaled-names)
135+
let argnames = :args
136+
eval(quote
137+
function c470($argnames...)
138+
return $argnames
139+
end
140+
end)
141+
end

0 commit comments

Comments
 (0)