Today I noticed that

```
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?

Today I noticed that

```
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?

1 Like

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

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

whereas what you really want is:

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

3 Likes