# Weird behavior: \`UndefVarError:\` module function needs to be called with ModuleName.function

**URL:** <https://discourse.julialang.org/t/weird-behavior-undefvarerror-module-function-needs-to-be-called-with-modulename-function/61790>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 25, 2021, 4:21pm UTC](https://discourse.julialang.org/t/weird-behavior-undefvarerror-module-function-needs-to-be-called-with-modulename-function/61790 "2021-05-25T16:21:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Post date:** [May 25, 2021, 4:21pm UTC](https://discourse.julialang.org/t/weird-behavior-undefvarerror-module-function-needs-to-be-called-with-modulename-function/61790/1 "2021-05-25T16:21:35Z")

</div>

This has come up a couple times for me but I’m daunted by the idea of getting an MRE because it is rare.

I write a non-exported helper function or method extension inside a module and it is undefined unless I call it with the full ModuleName.function even though it is only being used inside the module. Obviously it is easy to get the code to run, but it is annoying, and makes me feel like I am missing something.

here is code that errors:

```julia
module EscapeSimulator
#....

function equilibrium_sampler(θ, ab_profile_list)
    mapreduce( y -> map(x-> WrightSampler((x .* θ)...), y), vcat, ab_list)
end

function initialize_viral_population(θ::Float64, ab_ist)
    equilibrium_sampler = equilibrium_sampler(θ, ab_list)
    return equilibrium_sampler
end

#...
end

```

But this kind of thing works

```julia
module EscapeSimulator
#....

function equilibrium_sampler(θ, ab_list)
    mapreduce( y -> map(x-> WrightSampler((x .* θ)...), y), vcat, ab_list)
end

function initialize_viral_population(θ, ab_list)
    equilibrium_sampler = EscapeSimulator.equilibrium_sampler(θ, ab_list)
   # I need to specify the module -^ ?!
    return equilibrium_sampler
end

#...
end

```

Again this is not meant to be an MWE, I’m just wondering if other people have seen this kind of lost variable effect inside their modules and what it means. In the meantime I’ll try and get an MWE and will post an answer if I figure it out.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [May 25, 2021, 4:27pm UTC](https://discourse.julialang.org/t/weird-behavior-undefvarerror-module-function-needs-to-be-called-with-modulename-function/61790/3 "2021-05-25T16:27:42Z")

</div>

> [@cdawg](#):
>
> ` equilibrium_sampler = equilibrium_sampler(θ, ab_list)`

Isn’t the problem that you are redefining this name here, thus criating an ambiguity ?

---

<div class="post-metadata">

**Author:** ![cdawg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdawg/32/9811_2.png) [@cdawg](https://discourse.julialang.org/u/cdawg)\
**Post date:** [May 25, 2021, 4:34pm UTC](https://discourse.julialang.org/t/weird-behavior-undefvarerror-module-function-needs-to-be-called-with-modulename-function/61790/4 "2021-05-25T16:34:31Z")

</div>

Oh geeze yeah I guess maybe it’s calling the local variable I just created. 🤪
