Return type annotation with "where"

Not sure if I’m doing this wrong or perhaps this hasn’t been resolved yet: I can annotate the return type or I can have “where” in the function definition but I don’t know how to have both.

struct TypeA
end
something(s::TypeA)::Int = 1 # works
somethingor(s::T) where {T} = 1 # works
somethingorother(s::T)::Int where {T} = 1 #does NOT work
2 Likes

(somethingorother(s::T)::Int) where {T} = 1 # does work

Just add parenthesis

2 Likes

Splendid. Thanks!

1 Like

See also https://github.com/JuliaLang/julia/issues/21847.