Skip to content

Commit bc011bd

Browse files
author
Kristoffer Carlsson
authored
fix looking up definitions for kw methods (#90)
1 parent 719d51d commit bc011bd

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/utils.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ end
1919
checkname(fname::Symbol, name::Symbol) = begin
2020
fname === name && return true
2121
startswith(string(name), string('#', fname, '#')) && return true
22+
string(name) == string(fname, "##kw") && return true
2223
return false
2324
end
2425
checkname(fname::Symbol, ::Nothing) = true

test/runtests.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,13 @@ end
261261
body, _ = CodeTracking.definition(String, @which CallOverload(1)(1))
262262
@test body == "(f::CallOverload)(arg) = f.z + arg"
263263
end
264+
265+
if VERSION >= v"1.6.0"
266+
@testset "kwfuncs" begin
267+
body, _ = CodeTracking.definition(String, @which fkw(; x=1))
268+
@test body == """
269+
function fkw(; x=1)
270+
x
271+
end"""
272+
end
273+
end

test/script.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,7 @@ Foo.Bar.fit(a, b) = a + b
4343
function hasrettype(x::Real)::Float32
4444
return x*x + x
4545
end
46+
47+
function fkw(; x=1)
48+
x
49+
end

0 commit comments

Comments
 (0)