# Request to package developers: Please eliminate ambiguities with Base

**URL:** <https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123>\
**Category:** Community\
**Tags:** package, suggestions\
**Created:** [August 2, 2020, 8:43am UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123 "2020-08-02T08:43:47Z")\
**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:** [August 2, 2020, 8:43am UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123/1 "2020-08-02T08:43:47Z")

</div>

It’s often frustrating when you want your package to depend on an amazing package `A`, but doing do introduces ambiguities in `Base` functions that `A` has not eliminated. There are several packages that I’ve come across recently with this issue:

- [HTTP.jl](https://github.com/JuliaWeb/HTTP.jl/issues/548)

- [Unrolled.jl](https://github.com/cstjean/Unrolled.jl/issues/9)

- [FillArrays.jl](https://github.com/JuliaArrays/FillArrays.jl/issues/105)

The way to avoid this is often simply to put in

```julia
@test isempty(Test.detect_ambiguities(Base, Core, YourPackage))`

```

in your package’s `runtests.jl` after you’re done resolving the existing ones.

Methods ambiguities should be something that packages try to avoid. It’s possible that two packages `A` and `B` extend `Base` methods in a way that is ambiguous when one imports them both in the same session, and such issues might be harder to anticipate as a developer. However there’s no reason why `A` and `B` shouldn’t eliminate standalone ambiguities.

---

<div class="post-metadata">

**Author:** ![thofma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thofma/32/1691_2.png) [@thofma](https://discourse.julialang.org/u/thofma)\
**Post date:** [August 2, 2020, 1:21pm UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123/2 "2020-08-02T13:21:27Z")

</div>

Is the following good or bad for a package? I would rather not put this into my `runtests.jl`.

```julia
julia> Test.detect_ambiguities(Base, Core, Hecke)
ERROR: StackOverflowError:
Stacktrace:
 [1] _methods_by_ftype at ./reflection.jl:858 [inlined]
 [2] _methods_by_ftype(::Any, ::Int64, ::UInt64) at ./reflection.jl:855
 [3] isambiguous(::Method, ::Method; ambiguous_bottom::Bool) at ./reflection.jl:1308
 [4] detect_ambiguities(::Module, ::Vararg{Module,N} where N; imported::Bool, recursive::Bool, ambiguous_bottom::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1446
 [5] detect_ambiguities(::Module, ::Vararg{Module,N} where N) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1421
 [6] top-level scope at REPL[7]:1

```

P.S.: Tried three packages, got three times the `StackOverflowError`.

---

<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:** [August 2, 2020, 3:12pm UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123/3 "2020-08-02T15:12:31Z")

</div>

This is interesting, I’ve not encountered this before. Perhaps it’s worth reporting this issue. I can reproduce this as

```julia
julia> using Hecke

julia> Test.detect_ambiguities(Base)
ERROR: StackOverflowError:
Stacktrace:
 [1] _methods_by_ftype at ./reflection.jl:841 [inlined]
 [2] _methods_by_ftype(::Any, ::Int64, ::UInt64) at ./reflection.jl:838
...

```

Edit: filed [an issue](https://github.com/JuliaLang/julia/issues/36883)

---

<div class="post-metadata">

**Author:** ![thofma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thofma/32/1691_2.png) [@thofma](https://discourse.julialang.org/u/thofma)\
**Post date:** [August 2, 2020, 4:00pm UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123/4 "2020-08-02T16:00:41Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)\
**Post date:** [August 2, 2020, 5:35pm UTC](https://discourse.julialang.org/t/request-to-package-developers-please-eliminate-ambiguities-with-base/44123/5 "2020-08-02T17:35:03Z")

</div>

> It’s often frustrating when you want your package to depend on an amazing package `A` , but doing do introduces ambiguities in `Base` functions that `A` has not eliminated.

If there’s no type piracy, then using package A cannot interfere with your usage of `Base`, unless you’re actually using the types from A, in which case it’s a “regular ambiguity”. Is that what you’re talking about?
