1

Suppose I have an interface:

pragma solidity 0.7.6;

interface Foo { function foo() public view returns(bool); }

And a simplistic implementation like a mock:

contract Bar is Foo {

function foo() public view returns(bool} { this; // silence state mutability warning return true; } }

This part:

this;

... sort of works. See here: Function overriding versus Solidity Compiler Warning: Function state mutability can be restricted to pure

It seems clean enough with truffle compile and hardhat compile but solidity-coverage still complains about it:

state mutability can be restricted to pure

Sure, but this is a false positive. We don't want to change any code. The perfectionist in me doesn't want to see alarming warnings where no issue exists.

Is there a better way to silence the warning?

Thanks :-)

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145

0 Answers0