I was trying to understand why my code fails to compile, and eventually reduced it enough to find out it is caused by a comment. Is that normal?
# PART 1 : atomics_test1.nim
type
VolatilePtr*[T] = distinct ptr T
proc toVolatilePtr*[T](t: var T): VolatilePtr[T] =
cast[VolatilePtr[T]](addr t)
when declared(atomicLoadN):
proc atomicLoadNSeqCST*[T: AtomType](p: VolatilePtr[T]): T {.inline.} =
atomicLoadN(cast[ptr[T]](p), ATOMIC_SEQ_CST)
## REMOVE ME!
# PART 2 : atomics_test2.nim
import atomics_test1
var my_vbyte {.volatile.}: byte = 42'u8
var my_vbyte_ptr: VolatilePtr[byte] = toVolatilePtr[byte](my_vbyte)
assert(atomicLoadNSeqCST(my_vbyte_ptr) == 42'u8)
The assert in PART 2 fails to compile, with message:
atomics_test2.nim(7, 25) template/generic instantiation from here
atomics_test1.nim(10, 16) Error: expression 'atomicLoadN(castptr [T], ATOMIC_SEQ_CST)' is of type 'byte' and has to be discarded
The terminal process terminated with exit code: 1
If I remove the comment "## REMOVE ME!" in PART 1, it works again!
many thanks, for posting this issue monster; this information is completely new to me.
unfortunately it´s not stated here: https://nim-lang.org/docs/docgen.html#introduction-documentation-comments