encore
encore copied to clipboard
Variable accessible after being consumed
In feature/capabilities
branch, one can consume a variable and then, for example, call a method on it. When the variable is consumed it is set to null
. That this occurs is statically known, so perhaps the programmer should be warned.
In terms of capabilities, consume
consumes a capability, so its loss should/could be tracked statically.
The following program illustrates the bug.
trait Box
trait Lid
require numberOfSeals : int
def seals() : int
this.numberOfSeals
passive class Chest : read Box + thread Lid
numberOfSeals : int
class Main
def main() : void {
let c = new Chest;
let d : read Box, e : thread Lid = consume c;
print c.seals() -- c is statically known to be null here.
}
This program results in a Segmentation fault:
dhcp-11-160:kappa dave$ ./consume
Segmentation fault: 11
Static tracking of consume
s is an important step in the quest for getting rid of null
!