`return` in contracts have undesirable effects, consider a change
Let we have such code:
import std::collections::list;
def IntList = List(<int>);
<*
@require {| IntList* l = (IntList*) data; return l.allocator && l.capacity; |}
*>
fn void f(void* data)
{
// ...
}
It fails compilation with the following error:
5: def IntList = List(<int>);
6:
7: <*
8: @require {| IntList* l = (IntList*) data; return l.allocator && l.capacity; |}
^
(/home/starleks/coding/probe/c3-sandbox/main.c3:8:50) Error: Expected ';'
This is due to return being handled as a token inside of contracts.
We could possibly replace this with something else, such as:
$return
$return()
$$return
$$RETURN
$RETURN
@return
$ret
$ret()
$$RET
$RET
@ret
$_
$$_
<*
@ensure $return() > 0
*>
fn int foo() { ... }
<*
@ensure $ret() > 0
*>
fn int foo() { ... }
<*
@ensure $_ > 0
*>
fn int foo() { ... }
An advantage would be that the lexer would no longer need to special case lexing for return inside of the <* *>
We have already $vaarg which is context-dependent compile time variable. Technically, we could explain the reason for $return or $ret the same.
{| |} is not in 0.7 now, but I still consider this as something that needs to change. However I am unsure what the exact name should be.
Ping
Since expression blocks are no longer a thing, return should no longer be an issue.
So I'm going to close this, but reopen it if there are further ambiguities around this.