Open
Description
It's possible to write the following:
function SubTest(a: int): (r: Result<string, int>)
function Test(): (r: Result<string, int>) {
var s :- SubTest(3);
Success(s)
}
but let's say I would like to assert that SubTest won't fail (because of some conditions in the inputs of SubTest).
In methods, it's possible to prefix the call to SubTest
with assert
, and it will emit the assertion. However, it's not possible for functions yet.
It would be however obvious that
function SubTest(a: int): (r: Result<string, int>)
function Test(): (r: Result<string, int>) {
var s :- assert SubTest(3);
Success(s)
}
should be rewritten to:
function SubTest(a: int): (r: Result<bool, int>)
function Test(): (r: Result<string, int>) {
var tmp := SubTest(3);
assert !tmp.IsFailure();
var s := tmp.Extract();
Success(s);
}
The same goes for the assume
and expect
keywords, since many users use function methods
, might use them for testing, and also to assume something before coming back to it and revisiting the keyword later.