I am pretty sure this is because of macro hygine
and that you need
macro modulenames_global(module_)
return quote
names($(esc(module_))
end
end
and that that will work the same no matter if it is invoked from the module it was defined in, vs being invoked from another module.
I don’t have a good way of explaining why this is the case though.