File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 11name = " ExplicitImports"
22uuid = " 7d51a73a-1435-4ff3-83d9-f097790105c7"
33authors = [" Eric P. Hanson" ]
4- version = " 1.13"
4+ version = " 1.13.1 "
55
66[deps ]
77Markdown = " d6f4376e-aef5-505a-96c1-9c027394607a"
Original file line number Diff line number Diff line change 196196# check if `leaf` is a function argument (or kwarg), but not a default value etc,
197197# which is part of a function definition (not just any function call)
198198function is_non_anonymous_function_definition_arg (leaf)
199- # a call who is a child of `function` or `=` is a function def
200- # (I think!)
201199 if parents_match (leaf, (K " call" ,)) && call_is_func_def (parent (leaf))
202200 # We are a function arg if we're a child of `call` who is not the function name itself
203201 return child_index (leaf) != 1
@@ -241,7 +239,8 @@ function call_is_func_def(node)
241239 p === nothing && return false
242240 # note: macros only support full-form function definitions
243241 # (not inline)
244- kind (p) in (K " function" , K " macro" ) && return true
242+ # must be first child of function/macro to qualify
243+ kind (p) in (K " function" , K " macro" ) && child_index (node) == 1 && return true
245244 return false
246245end
247246
Original file line number Diff line number Diff line change 1+ module Foo129
2+ foo () = 3
3+ h (f) = 4
4+ h (f, f2) = 4
5+ module Bar
6+ using .. Foo129: foo, h
7+ bar () = h (foo)
8+
9+ # we will test that the LHS foo is a function arg and the RHS ones are not
10+ bar2 (x, foo) = h (foo, foo)
11+ end # Bar
12+ end # Foo129
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ include("test_explicit_imports.jl")
7777include (" main.jl" )
7878include (" Test_Mod_Underscores.jl" )
7979include (" module_alias.jl" )
80+ include (" issue_129.jl" )
8081
8182@testset " ExplicitImports" begin
8283 @testset " deprecations" begin
@@ -680,6 +681,12 @@ include("module_alias.jl")
680681 non_function_args = filter (! is_function_definition_arg, leaves)
681682 missed = filter (x -> get_val (x) === :a , non_function_args)
682683 @test isempty (missed)
684+
685+ # https://github.com/JuliaTesting/ExplicitImports.jl/issues/129
686+ df = DataFrame (get_names_used (" issue_129.jl" ). per_usage_info)
687+ foos = subset (df, :name => ByRow (== (:foo )))
688+ @test only (subset (foos, :function_arg ). location) == " issue_129.jl:10:9"
689+ check_no_stale_explicit_imports (Foo129, " issue_129.jl" )
683690 end
684691
685692 @testset " has_ancestor" begin
You can’t perform that action at this time.
0 commit comments