Is there a way to highlight instances of function shadowing such as
julia> struct MyType end
julia> Matrix(::MyType) = ones(2,2)
Matrix (generic function with 1 method)
where a new
Matrix function is created in a module, instead of a method being added?
I don’t know the context, of course, but would it make sense to write
That’s how it should be written. I’m trying to find instances where it’s written incorrectly so that I can fix them.
You can check if a name was exported by Base and isn’t assigned the same thing in the current module:
isshadowed(name::Symbol, current::Module, origin::Module) = name in names(origin) && getproperty(current, name) !== getproperty(origin, name), called like
isshadowed(:Matrix, @__MODULE__, Base). Checking all the names at opportune times is the tricky bit.
Oh, sorry, I misinterpreted.