# Cannot interpolate function signature into function definition expression

**URL:** <https://discourse.julialang.org/t/cannot-interpolate-function-signature-into-function-definition-expression/36761>\
**Category:** Internals & Design\
**Tags:** metaprogramming, function\
**Created:** [March 30, 2020, 9:28pm UTC](https://discourse.julialang.org/t/cannot-interpolate-function-signature-into-function-definition-expression/36761 "2020-03-30T21:28:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benninkrs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benninkrs/32/3191_2.png) [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Post date:** [March 30, 2020, 9:28pm UTC](https://discourse.julialang.org/t/cannot-interpolate-function-signature-into-function-definition-expression/36761/1 "2020-03-30T21:28:33Z")

</div>

This seems to be a parser weakness:

```julia
julia> foosig = :( foo(x) )
:(foo(x))

julia> :( function $foosig 2*x end )
ERROR: syntax: expected "end" in definition of function "($ foosig)"

```

The error message is miselading: the parser actually wants to see parentheses after `$foosig`. Note that these related constructions do parse as expected:

```julia
julia> :( $foosig = 2*x )
:(foo(x) = 2x)

julia> fooname = :foo
:foo

julia> :( function $fooname(x) 2*x end )
:(function foo(x)
      #= none:1 =#
      2x
  end)

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 31, 2020, 8:57am UTC](https://discourse.julialang.org/t/cannot-interpolate-function-signature-into-function-definition-expression/36761/2 "2020-03-31T08:57:33Z")

</div>

I can replicate on `master`.

Please check if there is an existing issue for this, and open one if there isn’t.

---

<div class="post-metadata">

**Author:** ![benninkrs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benninkrs/32/3191_2.png) [@benninkrs](https://discourse.julialang.org/u/benninkrs)\
**Post date:** [March 31, 2020, 2:09pm UTC](https://discourse.julialang.org/t/cannot-interpolate-function-signature-into-function-definition-expression/36761/3 "2020-03-31T14:09:18Z")

</div>

There is an [issue](https://github.com/JuliaLang/julia/issues/25080) that was opened and closed 2 years ago with an argument that the construction in the first example shouldn’t be valid. I added a comment there that I think this issue should be revisited.
