# @kwdef not working for parametric struct

**URL:** <https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286>\
**Category:** General Usage\
**Created:** [June 14, 2019, 4:20am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286 "2019-06-14T04:20:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![phrmoy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phrmoy/32/8912_2.png) [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Post date:** [June 14, 2019, 4:20am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/1 "2019-06-14T04:20:46Z")

</div>

Hi there,  
I am super excited about `@kwdef` being added to Base. I believe it’s a great feature to make the code more robust. With that said, I can’t seem to get it to work with a parametric struct:

```julia
@kwdef struct A{T}
    a::T
end

```

This returns: “UndefVarError: T not defined.” I am not sure where to post about it so I posted here.  
Pedro

---

<div class="post-metadata">

**Author:** ![phrmoy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phrmoy/32/8912_2.png) [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Post date:** [June 14, 2019, 4:22am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/2 "2019-06-14T04:22:42Z")

</div>

It might be worth noting that `@with_kw` from Parameters.jl does work for the example above.

---

<div class="post-metadata">

**Author:** ![simonbyrne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simonbyrne/32/19_2.png) [@simonbyrne](https://discourse.julialang.org/u/simonbyrne)\
**Post date:** [June 14, 2019, 4:45am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/3 "2019-06-14T04:45:33Z")

</div>

This was fixed in Julia 1.1 (see [#29316](https://github.com/JuliaLang/julia/pull/29316)), so try upgrading?

---

<div class="post-metadata">

**Author:** ![phrmoy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phrmoy/32/8912_2.png) [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Post date:** [June 14, 2019, 4:51am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/4 "2019-06-14T04:51:54Z")

</div>

Thank you. I am however on the LTS version v1.0.3. So does that mean that it’s also fixed for v1.0.4?

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [June 14, 2019, 7:17am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/5 "2019-06-14T07:17:29Z")

</div>

No, because #29316 is not a bugfix, its a feature.

---

<div class="post-metadata">

**Author:** ![phrmoy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phrmoy/32/8912_2.png) [@phrmoy](https://discourse.julialang.org/u/phrmoy)\
**Post date:** [June 14, 2019, 8:57am UTC](https://discourse.julialang.org/t/kwdef-not-working-for-parametric-struct/25286/6 "2019-06-14T08:57:43Z")

</div>

Though I believe I know the difference between a feature and a bug fix, I am not clear on the fact that we have this feature on v1.0.3 that is not working correctly, and from I am reading, it is not fixed in v1.0.4 though a fix does exist? Sorry for the confusion.
