ConstructorMock.sol 929 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.20;
  3. contract ConstructorMock {
  4. bool foo;
  5. enum RevertType {
  6. None,
  7. RevertWithoutMessage,
  8. RevertWithMessage,
  9. RevertWithCustomError,
  10. Panic
  11. }
  12. error CustomError();
  13. constructor(RevertType error) {
  14. // After transpilation to upgradeable contract, the constructor will become an initializer
  15. // To silence the `... can be restricted to view` warning, we write to state
  16. foo = true;
  17. if (error == RevertType.RevertWithoutMessage) {
  18. revert();
  19. } else if (error == RevertType.RevertWithMessage) {
  20. revert("ConstructorMock: reverting");
  21. } else if (error == RevertType.RevertWithCustomError) {
  22. revert CustomError();
  23. } else if (error == RevertType.Panic) {
  24. uint256 a = uint256(0) / uint256(0);
  25. a;
  26. }
  27. }
  28. }