I have a bug I can't figure out. After some experimentation, I have been able to simplify it to this minimal program:
type T = distinct uint64
func f(x: T): T =
T(uint64(x) shl 63)
func `==`(x, y: T): bool {.borrow.}
const
x = T(1'u64)
y = f(x)
assert y == f(x)
The assert on the last line fails. If I replace the const with a let, everything works as expected. Similar examples with integer types other than uint64 also seem to work.
What am I missing here?
You are saying this is a bug in Nim? I was sure it was just me who had made some stupid newbie mistake.
OK, I'll report on github. Thank you.