Very true
Using include like that is usually not the best idea unless you’ve thought
about and understood your actions
I solution (depending what's in the file) could be to `include` it
If we call `$` explicitly, we get a more illuminating error message:
`Error: ambiguous call; both dollars.$(x: int64) [proc declared in
/path/to/lib/system/dollars.nim(14, 6)] and lib.$(i: Int_b) [func declared in
/path/to/lib.nim(3, 6)] match for: (Int_b)`
Ah, right, it's not a big - if you want to have a custom `$`, you need to use
`distinct int64` instead. The reason is that `int64` already has `$` defined
for it, so they conflict. It works in the same file because the local `$`
overrides the global one AFAIK.
For anyone curious for the exact source code, this seems to reproduce the
problem:
# lib.nim
type
Int_b* = int64
func `$`*(i: Int_b): string =
"somestring"
Run
# main.nim
import lib
var a: Int_b
echo a
I defined a type called int_b = int64 and defined a specific print format for
it using $. It works within the module its defined in however when I attempt to
print a int_b in another module I get this error message. I made sure to add
the * so it would import. I'm likely making a stupid mistake