I've been fighting a confusing compile time error while refactoring a larger
project based on arraymancer to use generics, I've then reduced it to a small
example.
The very same code compiles when included (or copy-pasted in caller scope), but
doesn't when imported.
barmod.nim
import arraymancer
proc bar*[V]() =
discard newTensor[float32](0).asType(V)
Run
main.nim
when true:
import barmod
# compile error
# Error: undeclared identifier: 'newTensor'
else:
# compiles successfully
include barmod
bar[int]()
Run
I know this is related to declarations available at [macro
callsite](https://github.com/mratsim/Arraymancer/blob/7d6d21cbcafda25201f4fd2fb481fb1316704813/src/arraymancer/tensor/ufunc.nim#L28),
and I've checked that `newTensor` is not available there, but why is it
working when calling proc is included and not imported?
Would you please explain me what is happening here?
`asType` proc is
[here](https://github.com/mratsim/Arraymancer/blob/7d6d21cbcafda25201f4fd2fb481fb1316704813/src/arraymancer/tensor/ufunc.nim#L22)
`Error: undeclared identifier: 'newTensor'` happens
[here](https://github.com/mratsim/Arraymancer/blob/7d6d21cbcafda25201f4fd2fb481fb1316704813/src/arraymancer/tensor/private/p_empty_tensors.nim#L46)
Thanks