# Shouldn't this throw an error?

**URL:** <https://discourse.julialang.org/t/shouldnt-this-throw-an-error/68898>\
**Category:** Internals & Design\
**Tags:** functions, multidispatch\
**Created:** [September 29, 2021, 1:33am UTC](https://discourse.julialang.org/t/shouldnt-this-throw-an-error/68898 "2021-09-29T01:33:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [September 29, 2021, 1:33am UTC](https://discourse.julialang.org/t/shouldnt-this-throw-an-error/68898/1 "2021-09-29T01:33:10Z")

</div>

I have inadvertently made this mistake:

```julia
F(x, f::F) where F = f(x)

julia> F(0.5, sin)
ERROR: MethodError: no method matching F(::Float64, ::typeof(sin))

```

Shouldn’t the first line throw and error or are there cases where that is useful?

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [September 29, 2021, 6:43am UTC](https://discourse.julialang.org/t/shouldnt-this-throw-an-error/68898/2 "2021-09-29T06:43:39Z")

</div>

I don’t see why we’d need to prohibit something like:

```julia
foo(x, ::typeof(foo)) = 3x
foo(x, g::G) where {G} = g(x)
foo(2, foo)
foo(2, abs2)

```

EDIT:  
Wrong answer, see below.

Maybe I shouldn’t answer questions at 3am. Obviously `::F` isn’t the same as `::typeof(F)`.

---

<div class="post-metadata">

**Author:** ![MarcMush](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcmush/32/18006_2.png) [@MarcMush](https://discourse.julialang.org/u/MarcMush)\
**Post date:** [September 29, 2021, 11:13am UTC](https://discourse.julialang.org/t/shouldnt-this-throw-an-error/68898/3 "2021-09-29T11:13:34Z")

</div>

the code with `F` twice doesn’t actually create a method:

```julia-repl
julia> F(x, f::F) where F = f(x)
F (generic function with 0 methods)

```
