Consensys/scribble

Scribble doesn't correctly handle private visiblity of state vars

cd1m0 opened this issue · 1 comments

cd1m0 commented

Scribble will accept and instrument the following code, even though it shouldn't:

contract Base {
    uint private x;
}

contract Child is Base {
     /// if_succeeds x == 42;
     function foo() public {}
}

The problem is that the annotation in the Child contract refers to a private state variable of the parent contract. Those cannot be accessed in the child class. This occurs for example when you have a token contract inheriting from @OpenZeppelin's ERC20 contract, that talks about the _balances state var.

There are 2 possible solutions:

  1. Fix the type-checker to reject annotations where we are talking about private state variables of base contracts
  2. Change the instrumentation to silently change the visiblity of referenced private state variables into 'internal', thus allowing annotations to talk about private state of base contracts.
cd1m0 commented

For now we decided to go with "1. Fix the type-checker to reject annotations where we are talking about private state variables of base contracts"