# What is ambiguous here?

**URL:** <https://discourse.julialang.org/t/what-is-ambiguous-here/104029>\
**Category:** General Usage\
**Created:** [September 19, 2023, 3:26pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029 "2023-09-19T15:26:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 19, 2023, 3:26pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/1 "2023-09-19T15:26:31Z")

</div>

Hi,

Why is this reported as ambiguous, and is it true? Practice shows it is not.

```julia
using Test
x = detect_ambiguities(GMT)

x[2]
(getindex(D::GMTdataset{T, N}, inds::Vararg{Int64, N}) where {T, N} @ GMT C:\Users\j\.julia\dev\GMT\src\gmt_types.jl:122,
 getindex(D::GMTdataset{T, N}, inds::Vararg{Symbol, N}) where {T, N} @ GMT C:\Users\j\.julia\dev\GMT\src\gmt_types.jl:137)

```

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [September 19, 2023, 3:28pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/2 "2023-09-19T15:28:44Z")

</div>

ambiguous when `N = 0`

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 19, 2023, 3:38pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/3 "2023-09-19T15:38:14Z")

</div>

But in that case `GMTdataset{T, N}` would be empty and an error would have occurred before when trying to access an empty object.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [September 19, 2023, 3:50pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/4 "2023-09-19T15:50:07Z")

</div>

Sure, but Julia doesn’t know that by the method signatures alone. Simple example:

```julia
julia> f(::Array{T,N}, ::Vararg{Int64, N}) where {T,N} = "ints!"
f (generic function with 1 method)

julia> f(::Array{T,N}, ::Vararg{Symbol, N}) where {T,N} = "symbols!"
f (generic function with 2 methods)

julia> f(zeros((3, 5)), 1, 2)
"ints!"

julia> f(zeros((3,)), :one)
"symbols!"

julia> f(zeros(()))
ERROR: MethodError: f(::Array{Float64, 0}) is ambiguous. Candidates:
  f(::Array{T, N}, ::Vararg{Int64, N}) where {T, N} in Main at REPL[19]:1
  f(::Array{T, N}, ::Vararg{Symbol, N}) where {T, N} in Main at REPL[20]:1
Possible fix, define
  f(::Array{T, 0}) where T

```

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 19, 2023, 4:14pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/5 "2023-09-19T16:14:32Z")

</div>

Ok, thanks, I understand that case. But shouldn’t it be equivalent to this case where the `GMTdataset` type is used? No error here.

```julia
julia> D = GMTdataset()
String[]

julia> typeof(GMTdataset())
GMTdataset{Float64, 2}

julia> length(GMTdataset())
0

```

only if I do

```julia
julia> D[1]
ERROR: BoundsError: attempt to access 0×0 GMTdataset{Float64, 2} at index [1]

```

So, the ambiguity never really happens.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [September 19, 2023, 4:36pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/6 "2023-09-19T16:36:24Z")

</div>

The ambiguity never happens but it still exists.

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [September 19, 2023, 4:51pm UTC](https://discourse.julialang.org/t/what-is-ambiguous-here/104029/7 "2023-09-19T16:51:14Z")

</div>

> [@joa-quim](#):
>
> `0×0 GMTdataset{Float64, 2}`

That’s a 2-dimensional dataset with zero elements. A theoretical [0-dimensional](https://docs.julialang.org/en/v1/manual/faq/#faq-array-0dim) dataset would be a `GMTdataset{Float64, 0}` and have exactly one element.

I think it’s worth adding that ambiguities aren’t necessarily a problem. Yes, they’re sometimes code smells of a bad design and they sometimes describe a case that you forgot about, but they can also describe an operation that’s otherwise nonsensical.

It can be useful to keep `Test.detect_ambiguities` empty just to help you find those problem cases, but there’s otherwise nothing wrong with leaving some ambiguities laying around.
