ericphanson / ExplicitImports.jl

Developer tooling for Julia namespace management: detecting implicit imports, improper explicit imports, and improper qualified accesses
https://ericphanson.github.io/ExplicitImports.jl/
MIT License
62 stars 2 forks source link

false positive in stale names with default value for function args #62

Open ericphanson opened 2 weeks ago

ericphanson commented 2 weeks ago

spotted since ExplicitImports says norm is stale in DataFrames, when it is not: https://github.com/JuliaData/DataFrames.jl/blob/027650418ab08bbe6b94f2cf42743839aa7a593e/src/abstractdataframe/abstractdataframe.jl#L524

Repro:

using LinearAlgebra: stale
f(norm=norm) = 1
ericphanson commented 2 weeks ago

This is pretty tricky, since the second norm (the default arg) should not really be see as inside the scope of f. BUT if we had f(norm=norm, b=norm) = b, then the norm in b=norm actually refers to the left-hand-side of the first arg, i.e. f("hi") = "hi". So in that sense, the default arg is in scope of f, in that it sees earlier default args. So the ordering in f(name1=name2, name3=name4) is basically name2, name1, name4, name3, in that we want to resolve each default arg, then the arg name, then the next default arg, etc.