# "T not defined" when defining parametric one-line function with return type

**URL:** <https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827>\
**Category:** Internals & Design\
**Created:** [February 23, 2021, 7:23am UTC](https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827 "2021-02-23T07:23:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wujinq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wujinq/32/22221_2.png) [@wujinq](https://discourse.julialang.org/u/wujinq)\
**Post date:** [February 23, 2021, 7:23am UTC](https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827/1 "2021-02-23T07:23:50Z")

</div>

I noticed the following seemingly weird error when defining an abstract generic type:

```julia
abstract type SomeAbstractType{T} end
func(x::SomeAbstractType{T})::Bool where {T} = error("func is not implemented.")

```

and getting an error like “ERROR: UndefVarError: T not defined”.  
However, if the return type is removed then no error occurs:

```julia
abstract type SomeAbstractType{T} end
func(x::SomeAbstractType{T}) where {T} = error("func is not implemented.")
# func (generic function with 1 method)

```

What’s going on here? (I use Julia 1.5)

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 23, 2021, 7:36am UTC](https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827/2 "2021-02-23T07:36:13Z")

</div>

seems to be a parsing edge case?

```julia
julia> function func(x::SomeAbstractType{T})::Bool where {T}
           error("func is not implemented.")
       end
func (generic function with 1 method)

```

---

<div class="post-metadata">

**Author:** ![wujinq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wujinq/32/22221_2.png) [@wujinq](https://discourse.julialang.org/u/wujinq)\
**Post date:** [February 23, 2021, 7:49am UTC](https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827/3 "2021-02-23T07:49:07Z")

</div>

Yes, rewriting the function definition with `function` keyword seems to eliminate the problem. Is there a bug in the parser, or is it designed to be so?

---

<div class="post-metadata">

**Author:** ![rfourquet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rfourquet/32/3610_2.png) [@rfourquet](https://discourse.julialang.org/u/rfourquet)\
**Post date:** [February 23, 2021, 9:08am UTC](https://discourse.julialang.org/t/t-not-defined-when-defining-parametric-one-line-function-with-return-type/55827/4 "2021-02-23T09:08:27Z")

</div>

It’s a known issue: [https://github.com/JuliaLang/julia/issues/21847](https://github.com/JuliaLang/julia/issues/21847)
