`Using` doesn't work inside custom module

I want to export a function from a custom module that uses some package inside itself, but it works in a unexpected way for me

module A
export f
using StatsBase
f(x) = StatsBase.sample([x,0])
end

using .A
f(1)

Output
UndefVarError: StatsBase not defined

Stacktrace:
 [1] fff(::Int64) at ./In[1]:3
 [2] top-level scope at In[7]:2
 [3] include_string(::Function, ::Module, ::String, ::String) at ./loading.jl:1091

1 Like

This code is working for me (Julia 1.6). Can you try to copy-paste it in a fresh Julia instance? The stacktrace suggests that you have run something a bit different from the code shown here.

3 Likes

Yep, I edited names before posting. After restarting the Julia everything works, I don’t know why, thanks

1 Like