4 ms·
The only required enforcement is runtime (even then it is optional). However nothing stops the compiler from detecting a violation at compile and time failing
by bluGill 2mo ago
The only required enforcement is runtime (even then it is optional). However nothing stops the compiler from detecting a violation at compile and time failing because of an error (or perhaps warning?)
There is a lot of interest in static analysis enforcing contracts, but this will likely require some additions to the contract specification.
- steveklabnik 2mo agoI mean, what stops it is > this will likely require some additions to the contract specification. You need a lot more machinery to move this stuff to compile time, and not everything can be checked at compile time. The first example in the post would require you to validate that a <= v's len before indexing in order to be evaluated at compile time, for example. (Which of course is a runtime check anyway...)