# What is happening in this method definition "(generic function with 0 methods)"?

**URL:** <https://discourse.julialang.org/t/what-is-happening-in-this-method-definition-generic-function-with-0-methods/93363>\
**Category:** Internals & Design\
**Created:** [January 22, 2023, 3:10pm UTC](https://discourse.julialang.org/t/what-is-happening-in-this-method-definition-generic-function-with-0-methods/93363 "2023-01-22T15:10:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [January 22, 2023, 3:10pm UTC](https://discourse.julialang.org/t/what-is-happening-in-this-method-definition-generic-function-with-0-methods/93363/1 "2023-01-22T15:10:08Z")

</div>

```julia
julia> struct S{T} end

julia> T(::S{T}) where {T <: Any} = one(T)
T (generic function with 0 methods)

```

It seems Julia is confused by the function name being the same as a type parameter. I guess Julia should throw an error here instead of defining a function without the method?

EDIT: Issue on Github:

> <https://github.com/JuliaLang/julia/issues/33537>
>
> I encountered the following behavior, which is just odd:
> \`\`\`
> julia\> T(a, b, c)… where T = 1
> T (generic function with 0 methods)
> \`\`\`
> Apparently what happened was:
> 1. It created a method \`T\`
> 2. It added the defined method to something else (\`TypeVar\`, \`Any\` - one of them anyway)
> 3. It returned the method \`T\`
> 
> According to @JeffBezanson this should do "something else, whatever it may be", so here's the issue for that.

---

<div class="post-metadata">

**Author:** ![mikmoore](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikmoore/32/31109_2.png) [@mikmoore](https://discourse.julialang.org/u/mikmoore)\
**Post date:** [January 23, 2023, 6:59pm UTC](https://discourse.julialang.org/t/what-is-happening-in-this-method-definition-generic-function-with-0-methods/93363/2 "2023-01-23T18:59:47Z")

</div>

Yes, it’s weird that a function was defined but no method was added nor was there an error. It’s beyond my depth to understand what happened here.

In case you haven’t found it yet, you were probably looking for this

```julia-repl
julia> (::Type{T})(::S{T}) where T = one(T)

julia> Float64(S{Float64}())
1.0

```
