Open wandernauta opened 3 days ago
@wandernauta For context, VerCors supports some degree of first class permissions:
class C {
int x;
}
void m(C c) {
resource a = Perm(c.x, 1);
exhale a;
}
Currently it's not the case because of some other bug but that's an easy fix.
I'll have a quick look to see if it's worth fixing this because the support is quite experimental, so I might just put a try/catch wrapper around it for a friendly message.
To fix this, we need to make sure Return
is actually typechecked. This can be done by adding an intermediate AmbiguousReturn(Expr)
, which is transformed into a Return(Expr, Ref[AbstractMethod])
after the resolution phase. Typechecking then needs to be added here:
This is a bit of a bigger project because, while the AST changes are logical and straightforward, it's not really clear how many passes require extra bookkeeping to construct a proper back pointer to the successor of the current method being rewritten. For now I'm just adding a proper error that resource values as method return types are not supported with a link to this issue.
In the wiki, the type
resource
is described as a "Boolean-like type" in the specification language, noting that...And indeed the following PVL program verifies:
The following program also verifies (note that
bar
is notpure
):However, the following program causes VerCors to crash with a NoSuchElementException:
If
bar
is markedpure
, the error goes away.Version: 3313255 (dev branch).
This issue was found by fuzzing.