Skip to content

Commit 6a4a51b

Browse files
author
Kristoffer Carlsson
authored
fix callable struct without struct name lookup (#99)
1 parent 426fc0e commit 6a4a51b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function checkname(fdef::Expr, name)
55
(fdef.head === :where || fdef.head == :(::)) && return checkname(fproto, name)
66
fdef.head === :call || return false
77
if fproto isa Expr
8-
fproto.head == :(::) && return fproto.args[2] == name
8+
fproto.head == :(::) && return last(fproto.args) == name
99
# A metaprogramming-generated function
1010
fproto.head === :$ && return true # uncheckable, let's assume all is well
1111
# Is the check below redundant?

test/runtests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,14 @@ struct CallOverload
264264
z
265265
end
266266
(f::CallOverload)(arg) = f.z + arg
267+
struct Functor end
268+
(::Functor)(x, y) = x+y
267269
@testset "call syntax" begin
268270
body, _ = CodeTracking.definition(String, @which CallOverload(1)(1))
269271
@test body == "(f::CallOverload)(arg) = f.z + arg"
272+
273+
body, _ = CodeTracking.definition(String, @which Functor()(1,2))
274+
@test body == "(::Functor)(x, y) = x+y"
270275
end
271276

272277
if VERSION >= v"1.6.0"

0 commit comments

Comments
 (0)