# Disappearing methods from loaded libraries, seemingly iff \`using PreallocationTools\`

**URL:** <https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496>\
**Category:** General Usage\
**Tags:** sciml, methods, preallocation\
**Created:** [January 25, 2023, 10:18am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496 "2023-01-25T10:18:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joaovgranja](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaovgranja/32/42930_2.png) [@joaovgranja](https://discourse.julialang.org/u/joaovgranja)\
**Post date:** [January 25, 2023, 10:18am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/1 "2023-01-25T10:18:47Z")

</div>

I have a weird issue that I am unable to reproduce in a MWE. It happens in the context of a reasonably large project.

Some methods are not available despite their libraries being loaded. For instance:

```julia
MethodError: no method matching dot(::Vector{Float64}, ::Vector{Float64})

```

Indeed, `methods(dot)` returns 0 methods, despite `LinearAlgebra` being loaded. The same happened recently, in the same project, with `Base.collect`.

From some experimentation, it seems to be the case that the issue occurs if and only if `PreallocationTools` (which is awesome!) is loaded. However, I was unable to reproduce that behaviour in a MWE.

Any pointers to what the issue could be would be much appreciated. Cheers.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 25, 2023, 10:33am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/2 "2023-01-25T10:33:24Z")

</div>

I would need an MWE to see what’s going on there. PreallocationTools.jl is both small and does nothing particularly odd, you can read the whole source in like 15 minutes:

> <https://github.com/SciML/PreallocationTools.jl/blob/master/src/PreallocationTools.jl>

I would think PreallocationTools is a red herring here and it’s actually something completely different.

---

<div class="post-metadata">

**Author:** ![joaovgranja](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaovgranja/32/42930_2.png) [@joaovgranja](https://discourse.julialang.org/u/joaovgranja)\
**Post date:** [January 25, 2023, 10:39am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/3 "2023-01-25T10:39:06Z")

</div>

Fair enough. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![fatteneder](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fatteneder/32/33991_2.png) [@fatteneder](https://discourse.julialang.org/u/fatteneder)\
**Post date:** [January 25, 2023, 11:06am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/4 "2023-01-25T11:06:31Z")

</div>

I hit this too some time ago, but I wasn’t really sure either if it is me that messed things up or if it is a bug.

Just revisted my notes from back then and came up with this MWE:

```julia
module shadow

using LinearAlgebra

dot(x,y) = sum(x .* y) - 1

end # module shadow

```

Fire up a REPL and run

```julia
julia> methods(shadow.dot)
# 42 methods for generic function "dot":
...

```

Kill the REPL, comment the definition of `dot` and run again

```julia
julia> methods(shadow.dot)
# 1 method for generic function "dot":
...

```

So it seems to me that there is some silent shadowing going on with exported (and overridden) methods.

The above was tested on `julia v1.8` but I have also seen it on `julia v1.7` or even `julia v1.6` (I believe it was).

EDIT: Might be related [No error when method definition shadows local variable · Issue #15510 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/15510)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 25, 2023, 11:14am UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/5 "2023-01-25T11:14:11Z")

</div>

That’s what I would guess. But `dot` is neither imported, used, nor exported from PreallocationTools. It does not show up in the source at all. So something is shadowing it, but not PreallocationTools. Are you sure @joaovgranja you don’t have a `dot(x,y) = ...` overload somewhere and forgot to `LinearAlgebra.dot(x,y)`?

---

<div class="post-metadata">

**Author:** ![joaovgranja](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joaovgranja/32/42930_2.png) [@joaovgranja](https://discourse.julialang.org/u/joaovgranja)\
**Post date:** [January 25, 2023, 4:15pm UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/6 "2023-01-25T16:15:52Z")

</div>

That was my first suspicion too, but no, I haven’t overloaded `dot`. And the same issue happens with `Base.collect`, which is also not overloaded. Still unable to track the issue down. Thanks for the MWE, @fatteneder!

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [January 25, 2023, 4:32pm UTC](https://discourse.julialang.org/t/disappearing-methods-from-loaded-libraries-seemingly-iff-using-preallocationtools/93496/7 "2023-01-25T16:32:50Z")

</div>

> [@joaovgranja](#):
>
> `methods(dot)` returns 0 methods

`parentmodule(dot)` should point to the module.
