Assert keyword

The assert keyword is used to statically assert that some expression is true. The expression must be a compile-time constant, and be of type i32.

Note that what currently qualifies as a compile-time constant is quite constrained, as the compiler does not have a complete constant evaluation system. This issue will hopefully be addressed in a future version quite soon.

Examples

This shows the basic use of assertions in Water code.

Asserts can be useful for constraining which types can be passed to a generic function: