This seems like such a simple thing, but I don't know why this isn't working.
I have a module hot.nim that gets imported and exported by another module gdnim.nim. And I want to use my macro hot.save() in another module that imports gdnim.
But when I do I get undeclared identifier: hot. If I don't qualify save() my module compiles. So how do I get hot.save() to compile?
#hot.nim
macro save*()
discard
#gdnim.nim
import hot
export hot
#mymodule.nim
import gdnim
hot.save() # Error: undeclared identifier: 'hot'
I just tried gdnim.hot.save() and that works, but it's not ideal if I have exports several modules deep.
Anyway, I guess I didn't try fully qualifying the identifier immediately because I was tripped up by an error message about an ambiguous call when another module had the same exported identifier:
Error: ambiguous call; both hot.save(args: varargs[typed]) [macro declared in C:\godot\gdnim\gdnim\hot.nim(24, 7)] and project_settings.save() [proc declared in C:\godot\gdnim\deps\godotapi\project_settings.nim(235, 6)] match for: ()
use this trick to simulate namespace
# hot.nim
type
hot* = object
macro save*(_: type[hot] = hot) =
discard
# mymodule.nim
import gdnim
hot.save()
save()