mutability_15.sol 535 B

12345678910111213141516
  1. contract C {
  2. string s;
  3. function test(string calldata x) public pure returns (string memory) {
  4. s = "foo";
  5. s = x;
  6. print(s);
  7. return s;
  8. }
  9. }
  10. // ---- Expect: diagnostics ----
  11. // error: 5:9-10: function declared 'pure' but this expression writes to state
  12. // error: 6:9-10: function declared 'pure' but this expression writes to state
  13. // error: 7:15-16: function declared 'pure' but this expression reads from state
  14. // error: 8:16-17: function declared 'pure' but this expression reads from state