You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
check-magic: Remember all explained magic constants
Previously, scripts/check-magic would remember only the last explained
magic constant, preventing, for example, the explanation of multiple
magic constants ahead of a comment block referring to all of them.
Moreover, check-magic would only lazily evaluate a provided explanation
when actually finding a magic value magic the LHS of the proposed
explanation. In particular, a _wrong_ explanation would only be caught
if, in the rest of the file under consideration, some matching magic
constant would be found.
This commit makes check-magic more general so that
- it always checks magic value explanations when they are provided,
regardless of whether they are needed or not; and,
- it remembers all magic values explained so far.
Moreover, the `round` function is instrumented to fail if it is
called on an odd multiple of 1/2 -- in this case, the rounding
is ambiguous (do we want round-half-down or round-half-up?).
We also add support for `intdiv(a,b)` to an integer division which we
want to assert to be without residue. This can be used instead of `//`
to additionally check that the division is indeed integral.
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
0 commit comments