This feature would require adding 3 keywords: return, break and continue. The first one returns from a procedure and should check if the return types match. The break stops the loop and jumps to the end of it and continue stops the current iteration and jumps to the condition checking. The latter two should check, that the types match those at the regular end of the loop and those, that are on the stack before before the loop starts.
It is important, that those keywords impact branch type checking, so if you are guaranteed to return in a branch there should be no type checking at the end. For example the following code should compile even though the type checking without the return would fail.
nproc dealloc ptr p:
if p NULL ptr== do
return p p
end
p free
end
This feature would require adding 3 keywords: return, break and continue. The first one returns from a procedure and should check if the return types match. The break stops the loop and jumps to the end of it and continue stops the current iteration and jumps to the condition checking. The latter two should check, that the types match those at the regular end of the loop and those, that are on the stack before before the loop starts.
It is important, that those keywords impact branch type checking, so if you are guaranteed to return in a branch there should be no type checking at the end. For example the following code should compile even though the type checking without the return would fail.