Current_module() vs @__MODULE__ / They are not equivalent

julia> module XXX
               export foo,bar
               function foo(amod::Module = current_module())
                       println(amod)
               end

               function bar(amod::Module = @__MODULE__)
                       println(amod)
               end
       end
Main.XXX

julia> module YYY
               using Main.XXX
               export f,g
               function f()
                       foo()
               end

               function g()
                       bar()
               end
       end
Main.YYY

julia> using Main.YYY

julia> f()
┌ Warning: `current_module()` is deprecated, use `@__MODULE__` instead.
│   caller = foo at REPL[1]:4 [inlined]
└ @ Core REPL[1]:4
Main

julia> g()
Main.XXX

How can i get the old current_module() functionality?

There’s no equivalent. The exact fix of this depending on what you are actually using this for at a higher level

I am trying to achieve the functionality of foo() which is giving me the module wherever i am calling the function.

That is exactly the thing that is not possible. You need to figure out why you need that behavior.

Or in another word, what does your function do, what does it operate on the module and why does it care about the module the top-level code is running in.