Skip to content

Commit 1a1d7ab

Browse files
authored
Handle interpolated arguments (#110)
Fixes JuliaDebug/Cthulhu.jl#425
1 parent 65d259b commit 1a1d7ab

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "CodeTracking"
22
uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
33
authors = ["Tim Holy <[email protected]>"]
4-
version = "1.3.0"
4+
version = "1.3.1"
55

66
[deps]
77
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ function is_func_expr(@nospecialize(ex), meth::Method)
118118
margs = margs[idx:end]
119119
end
120120
for (arg, marg) in zip(exargs, margs[2:end])
121+
isexpr(arg, :$) && continue
121122
aname = get_argname(arg)
122123
aname === :_ && continue
123124
aname === marg || (aname === Symbol("#unused#") && marg === Symbol("")) || return false

test/runtests.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,40 +202,44 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
202202
src, line = definition(String, m)
203203
@test occursin("xf", src)
204204
@test line == 85
205+
m = which(dollaratan, (Real, Real))
206+
src, line = definition(String, m)
207+
@test occursin("atan(y, x)", src)
208+
@test line == 93
205209

206210
# unnamed arguments
207211
m = which(unnamedarg, (Type{String}, Any))
208212
src, line = definition(String, m)
209213
@test occursin("string(x)", src)
210-
@test line == 93
214+
@test line == 98
211215
m = which(mypush!, (Nowhere, Any))
212216
src, line = definition(String, m)
213217
@test occursin("::Nowhere", src)
214-
@test line == 108
218+
@test line == 113
215219

216220
# global annotations
217221
m = which(inlet, (Any,))
218222
src, line = definition(String, m)
219223
@test occursin("inlet(x)", src)
220-
@test line == 112
224+
@test line == 117
221225

222226
# Callables
223227
gg = Gaussian(1.0)
224228
m = @which gg(2)
225229
src, line = definition(String, m)
226230
@test occursin("::Gaussian)(x)", src)
227-
@test line == 119
231+
@test line == 124
228232
invt = Invert()
229233
m = @which invt([false, true])
230234
src, line = definition(String, m)
231235
@test occursin("::Invert)(v", src)
232-
@test line == 121
236+
@test line == 126
233237

234238
# Constructor with `where`
235239
m = @which Invert((false, true))
236240
src, line = definition(String, m)
237241
@test occursin("(::Type{T})(itr) where {T<:Invert}", src)
238-
@test line == 122
242+
@test line == 127
239243

240244
# Invalidation-insulating methods used by Revise and perhaps others
241245
d = IdDict{Union{String,Symbol},Union{Function,Vector{Function}}}()

test/script.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ for f in (:mysin,)
8989
end
9090
end
9191
mysin(x::AbstractFloat) = sin(x)
92+
let args = [:(y::Real), :(x::Real)]
93+
@eval function dollaratan($(args...))
94+
return atan(y, x)
95+
end
96+
end
9297

9398
unnamedarg(::Type{String}, x) = string(x) # see more unnamed on line 108
9499

0 commit comments

Comments
 (0)