One-liner definition of generated functions with where syntax


#1

Is there a particular reason why the first definition doesn’t work?

julia> @generated foo(x::T) where T = x
ERROR: invalid syntax; @generated must be used with a function definition

julia> @generated foo(x::T where T) = x
foo (generic function with 1 method)

Is this a bug or a feature? I’m running Julia 0.7.0-DEV.363 (Commit 6071f1a02e).

@inline decorator instead works (I know that this defines a different function, I’m just showing the different behavior):

julia> @inline foo(x::T) where T = x
foo (generic function with 1 method)

Edit: reported on GitHub at https://github.com/JuliaLang/julia/issues/22135

Edit 2: fixed, together with a bunch of other bugs, with https://github.com/JuliaLang/julia/pull/22166