2 ms·
Are those (non-Enum) precondition value constraints checked at compile-time or at runtime?
by westurner 3y ago
Are those (non-Enum) precondition value constraints checked at compile-time or at runtime?
- threeseed 3y agoCompile time. But obviously only for values that are determined within the code.
- westurner 3y agoWhat does Rust do at runtime if you pass a non-const to a const field at a low level at runtime? If there's no runtime type or and value constraint checking, IMHO it shouldn't be considered proven at all. IIUC e.g. NASA's guidelines specify hard preconditions at the top of every function.
- westurner 3y agoFWIW, in Python, from https://news.ycombinator.com/item?id=38579378 https://news.ycombinator.com/item?id=38579378 : > Hypothesis generates tests from type annotations; and icontract and pycontracts do runtime type checking. Pynguin also generates tests; but it does not use icontract-style type and value constraints as decorator preconditions in generating tests. icontract-hypothesis: https://github.com/mristin/icontract-hypothesis https://github.com/mristin/icontract-hypothesis https://news.ycombinator.com/item?id=38138319 https://news.ycombinator.com/item?id=38138319