Delegating bind statements

The following example outlines a problem that can arise when generic instantiations cross multiple different modules:

  1. # module A
  2. proc genericA*[T](x: T) =
  3. mixin init
  4. init(x)
  1. import C
  2. # module B
  3. proc genericB*[T](x: T) =
  4. # Without the `bind init` statement C's init proc is
  5. # not available when `genericB` is instantiated:
  6. bind init
  7. genericA(x)
  1. # module C
  2. type O = object
  3. proc init*(x: var O) = discard
  1. # module main
  2. import B, C
  3. genericB O()

In module B has an init proc from module C in its scope that is not taken into account when genericB is instantiated which leads to the instantiation of genericA. The solution is to forward these symbols by a bind statement inside genericB.