JoinColony / solcover

Code coverage for solidity
MIT License
64 stars 8 forks source link

Handle empty function body edge case #11

Closed cgewecke closed 7 years ago

cgewecke commented 7 years ago

There is a very marginal edge case for parsing function declarations where the function body is empty and there are no spaces between the body brackets e.g.

function emptyBody(uint x){} 

An example of someone legitimately using this form can be seen in this gnosis contract.

Solcover near-misses getting the instrument event inside the function body here and errors with

Error: Instrumented solidity invalid: :8:49: Error: Expected identifier, got 'LParen'
    function emptyBody(uint x){}FunctionCoverage('test.sol',1);

This PR adds logic to check for the existence of this case and modifies the injection start point by one position.