It's like something breaks under a certain combination of factors
# base.nim
type Base*[T] = object
func `value=`*(base: Base, v: int) = discard
# foo.nim
import base
export base
const f* = Base[int]()
# misc.nim
import foo
proc setValue*[T](a: T) =
f.value = a
# main.nim
import misc
setValue(1)
$ nim c main.nim
...
misc.nim(2, 8) Warning: imported and not used: 'foo' [UnusedImport]
main.nim(3, 9) template/generic instantiation of `setValue` from here
misc.nim(4, 11) Error: attempting to call undeclared routine: 'value='
If you change f.value = a to f.`value=`(a)
# misc.nim
import foo
proc setValue*[T](a: T) =
f.`value=`(a)
then it compiles, but continues to output the wrong warning:
misc.nim(2, 8) Warning: imported and not used: 'foo' [UnusedImport]
If you make ' setValue` a regular function instead of a generic, then everything will work as it should.
# misc.nim
import foo
proc setValue*(a: int) =
f.value = a
This works without binding:
# misc.nim
import foo
proc setValue*[T](a: T) =
f.`value=`(a)