# Return type assertions with type parameters

**URL:** https://discourse.julialang.org/t/return-type-assertions-with-type-parameters/4984
**Category:** General Usage
**Created:** [July 20, 2017, 8:17pm UTC](https://discourse.julialang.org/t/return-type-assertions-with-type-parameters/4984 "2017-07-20T20:17:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)
#### Post date: [July 20, 2017, 8:17pm UTC](https://discourse.julialang.org/t/return-type-assertions-with-type-parameters/4984/1 "2017-07-20T20:17:09Z")

</div>

Today I noticed that

```julia
f(x::T)::T where T = x # throws UndefVarError for T
function f(x::T)::T where T
    x
end # works

```

Is this a bug?

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [July 20, 2017, 8:48pm UTC](https://discourse.julialang.org/t/return-type-assertions-with-type-parameters/4984/2 "2017-07-20T20:48:13Z")

</div>

I think it’s just a surprising operator precedence. Your first form is parsed as

```julia
julia> :(f(x::T)::T where T)
:(f(x::T)::(T where T))

```

whereas what you really want is:

```julia
julia> (f(x::T)::T) where T = x
f (generic function with 1 method)

julia> f(1)
1

```
