rational_comparison2.sol 921 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. contract c {
  2. function eq() public returns (bool) {
  3. return 1.1 == 1.0;
  4. }
  5. function ne() public returns (bool) {
  6. return 1.1 != 1.0;
  7. }
  8. function lt() public {
  9. require(1.0 < 1.1);
  10. }
  11. function le(bool a) public {
  12. require(a && 0.1 <= 1.1);
  13. }
  14. function gt(bool a) public {
  15. if (1 > 0.5) { }
  16. }
  17. function gt(int a) public returns (bool) {
  18. return a > 1.1;
  19. }
  20. function ge(bool a) public {
  21. gt(1 >= 1.02);
  22. }
  23. }
  24. // ---- Expect: diagnostics ----
  25. // error: 3:10-20: cannot use rational numbers with '==' operator
  26. // error: 7:10-20: cannot use rational numbers with '!=' operator
  27. // error: 11:11-20: cannot use rational numbers with '<' operator
  28. // error: 15:16-26: cannot use rational numbers with '<=' operator
  29. // error: 19:7-14: cannot use rational numbers with '>' operator
  30. // error: 23:10-17: cannot use rational numbers with '>' operator
  31. // error: 27:6-15: cannot use rational numbers with '>=' operator