This part in _writeCheckpoint()
, if pos
, which is the length of the Checkpoint[]
, equals 0, why doesn't ckpts[pos - 1]
cause an underflow? Doesn't ==
precede &&
?
if (pos > 0 && ckpts[pos - 1].fromBlock == block.number) {
ckpts[pos - 1].votes = SafeCast.toUint224(newWeight);
}
Edit: it seems that the function will first recognize &&
, then if pos>0
is not true, it will not evaluate ckpts[pos - 1]
, is there a doc about it? As something like https://docs.soliditylang.org/en/v0.8.12/cheatsheet.html#order puts &&
in the last in precedence, so it may seem that the function will evaluate both two bools first then &&
at a glance.