mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Error on invalid arithmetic with constant expressions.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
contract C {
|
||||
uint constant a = addmod(3, 4, 0.1);
|
||||
uint constant b = mulmod(3, 4, 0.1);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (48-51): Invalid type for argument in function call. Invalid implicit conversion from rational_const 1 / 10 to uint256 requested.
|
||||
// TypeError: (89-92): Invalid type for argument in function call. Invalid implicit conversion from rational_const 1 / 10 to uint256 requested.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract c {
|
||||
uint constant a1 = 0;
|
||||
uint constant a2 = 1;
|
||||
uint constant b1 = addmod(3, 4, 0);
|
||||
uint constant b2 = addmod(3, 4, a1);
|
||||
uint constant b3 = addmod(3, 4, a2 - 1);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (88-103): Arithmetic modulo zero.
|
||||
// TypeError: (128-144): Arithmetic modulo zero.
|
||||
// TypeError: (169-189): Arithmetic modulo zero.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract c {
|
||||
uint constant a1 = 0;
|
||||
uint constant a2 = 1;
|
||||
uint constant b1 = 7 / a1;
|
||||
uint constant b2 = 7 / (a2 - 1);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (88-94): Division by zero.
|
||||
// TypeError: (119-131): Division by zero.
|
||||
@@ -0,0 +1,6 @@
|
||||
contract C {
|
||||
fixed a1 = 0.1 % -0.4271087646484375;
|
||||
fixed a2 = 0.1 % 0.4271087646484375;
|
||||
fixed a3 = 0 / 0.123;
|
||||
fixed a4 = 0 / -0.123;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
contract c {
|
||||
uint constant a1 = 0;
|
||||
uint constant a2 = 1;
|
||||
uint constant b1 = 3 % a1;
|
||||
uint constant b2 = 3 % (a2 - 1);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (88-94): Modulo zero.
|
||||
// TypeError: (119-131): Modulo zero.
|
||||
@@ -0,0 +1,11 @@
|
||||
contract c {
|
||||
uint constant a1 = 0;
|
||||
uint constant a2 = 1;
|
||||
uint constant b1 = mulmod(3, 4, 0);
|
||||
uint constant b2 = mulmod(3, 4, a1);
|
||||
uint constant b3 = mulmod(3, 4, a2 - 1);
|
||||
}
|
||||
// ----
|
||||
// TypeError: (88-103): Arithmetic modulo zero.
|
||||
// TypeError: (128-144): Arithmetic modulo zero.
|
||||
// TypeError: (169-189): Arithmetic modulo zero.
|
||||
Reference in New Issue
Block a user