yul_switch.sol 492 B

1234567891011121314151617181920
  1. contract testTypes {
  2. uint256 b;
  3. function testAsm(uint128[] calldata vl) public view returns (uint256) {
  4. uint256 y = 0;
  5. assembly {
  6. switch vl.length
  7. case 1 {y := mul(b.slot, 2)}
  8. case 2 {y := shr(b.offset, 2)}
  9. default {
  10. y := 5
  11. }
  12. y := sub(y, 1)
  13. }
  14. return y;
  15. }
  16. }
  17. // ---- Expect: diagnostics ----
  18. // warning: 3:5-74: function declared 'view' can be declared 'pure'