Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

assert

use Core.assert

The assert module provides a single assert function, which returns an error if the given condition evaluates to false. It is used for code-assertions and to fail loud and clear.

Function NameParameter TypesReturn TypesPossible Errors
assertboolNoErrAssert

error sets

These are the error sets this Core module provides.

ErrAssert

This error set does not have a parent error, so it directly and only extends anyerror directly. These are the possible values this error could have:

Error ValueDescription
AssertionFailedThe assertion has failed

assert

use Core.assert

def main():
    i32 x = 5;
    assert(x > 6);

When executing this program you will see this error message printed to the console:

ERROR: main function returned error
 - type_id: 2448605372
 - value_id: 0
 - message: "The assertion has failed"