Closed auxym closed 4 years ago
Sounds good but would require https://github.com/nim-lang/RFCs/issues/126
Alternatively we could handle @[] as the same as @[0]. I'd accept a PR that adds this.
Yeah, I wasn't sure if/how it could be implemented in Nim. Good to know there's an RFC about it!
Consider the following:
This results in the following stack trace:
This is because
a.limbs
is@[]
. Would it be possible for an uninitializedBigInt
to default tolimbs = @[0]
, to be consistent with nim integers? Otherwise, maybe there could be a flaginitialized
that is checked before trying to operate on aBigInt
, so we get slightly more readable errors. I'm not super proud about it, but tbh this took me a while to debug. To be fair, my actual code was slightly more complex and resulted in a zero BigInt not being initialized in a corner case.