Skip to content

Try/Catch should be treated as branch #852

Open
@cgewecke

Description

This is mostly only helpful if you have an empty catch clause. Normally the contents of the blocks are treated as lines and statements so you can tell they weren't hit. And the try statement itself is covered.

Example of a place where it could be overlooked is at zeppelin:GovernorTimelockAccess.sol

// It is important that all calls have an opportunity to be cancelled. We chose to ignore
// potential failures of some of the cancel operations to give the other operations a chance to
// be properly cancelled. In particular cancel might fail if the operation was already cancelled
// by guardians previously. We don't match on the revert reason to avoid encoding assumptions
// about specific errors.
try _manager.cancel(address(this), targets[i], calldatas[i]) {} catch {}

This semantic structure is kind of complicated - there can be multiple catch clauses etc. Maybe only treat the empty catch clause case as a branch...not sure that makes it any easier to implement though.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions