# What is wrong with getfield?

**URL:** <https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105>\
**Category:** General Usage\
**Created:** [July 2, 2018, 7:13pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105 "2018-07-02T19:13:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [July 2, 2018, 7:13pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105/1 "2018-07-02T19:13:22Z")

</div>

```nohighlight

module RRW
  struct YU
  end
end

const modsym = RRW

getfield(modsym,:YU)

```

ERROR: UndefVarError: YU not defined

this doesn’t happen when i do the following:

```nohighlight
getfield(RRW,:YU)
RRW.YU

```

Why does this happen?

---

<div class="post-metadata">

**Author:** ![quinnj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quinnj/32/11_2.png) [@quinnj](https://discourse.julialang.org/u/quinnj)\
**Post date:** [July 2, 2018, 7:20pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105/2 "2018-07-02T19:20:52Z")

</div>

```julia
               _
   _ _ _(_)_ | A fresh approach to technical computing
  (_) | (_) (_) | Documentation: https://docs.julialang.org
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 0.7.0-beta.115 (2018-07-02 03:32 UTC)
 _/ |\ __'_|_|_|\__'_| | Commit b7dc60f7b4* (0 days old master)
|__/ | x86_64-apple-darwin16.7.0

julia> module RRW
       struct YU
       end
       end
Main.RRW

julia> const modsym = RRW
Main.RRW

julia> getfield(modsym, :YU)
Main.RRW.YU

```

---

<div class="post-metadata">

**Author:** ![Qiyamah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/qiyamah/32/2660_2.png) [@Qiyamah](https://discourse.julialang.org/u/Qiyamah)\
**Post date:** [July 2, 2018, 7:21pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105/3 "2018-07-02T19:21:33Z")

</div>

interesting, then this is happening only in v0.6  
is there a work around for this in v0.6?

```nohighlight
   _ _ _(_)_ | A fresh approach to technical computing
  (_) | (_) (_) | Documentation: https://docs.julialang.org
   _ _ _| |_ __ _ | Type "?help" for help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 0.6.2 (2017-12-13 18:08 UTC)
 _/ |\ __'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-pc-linux-gnu

```

Thanks

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [July 2, 2018, 8:34pm UTC](https://discourse.julialang.org/t/what-is-wrong-with-getfield/12105/4 "2018-07-02T20:34:27Z")

</div>

Works fine on 0.6.3 as well, so maybe just upgrade to that if it’s not working on 0.6.2?
