hhvm icon indicating copy to clipboard operation
hhvm copied to clipboard

Introduce [pure] as coeffects bottom type

Open muglug opened this issue 4 years ago • 0 comments

The current coeffects system allows you to describe a pure function by using the empty set [] annotation:

function someFunc(int $x)[] {
  return $x + 1;
}

While this makes sense given the system described, it's easy to miss when scanning code:

function someFunc(int $x)[] { // no effects allowed
vs
function someFunc(int $x) { // all effects allowed

What if you instead required an explicit pure keyword:

function someFunc(int $x)[pure] {
  return $x + 1;
}

It would be the bottom type of the system, so [pure, io] would be treated as [io] (and would presumably also be flagged by the typechecker).

muglug avatar Apr 15 '21 19:04 muglug