# How to flag Base functions that are being shadowed?

**URL:** https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289
**Category:** General Usage
**Tags:** linter
**Created:** [July 31, 2023, 5:55am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289 "2023-07-31T05:55:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [July 31, 2023, 5:55am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289/1 "2023-07-31T05:55:30Z")

</div>

Is there a way to highlight instances of function shadowing such as

```julia
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?

---

<div class="post-metadata">

### Author: ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)
#### Post date: [July 31, 2023, 6:07am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289/2 "2023-07-31T06:07:15Z")

</div>

I don’t know the context, of course, but would it make sense to write `Base.Matrix(::MyType) =...`?

---

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [July 31, 2023, 6:09am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289/3 "2023-07-31T06:09:25Z")

</div>

That’s how it should be written. I’m trying to find instances where it’s written incorrectly so that I can fix them.

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [July 31, 2023, 10:22am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289/4 "2023-07-31T10:22:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)
#### Post date: [July 31, 2023, 10:40am UTC](https://discourse.julialang.org/t/how-to-flag-base-functions-that-are-being-shadowed/102289/5 "2023-07-31T10:40:30Z")

</div>

Oh, sorry, I misinterpreted.
