mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Generate warning when rational numbers are converted to their mobile type without explicit requests
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
contract TestTernary
|
||||
{
|
||||
function g() pure public
|
||||
{
|
||||
bool t = true;
|
||||
bool f = false;
|
||||
uint8 v255 = 255;
|
||||
uint8 v63 = 63;
|
||||
uint8 a;
|
||||
|
||||
// Currently none of these should produce errors or warnings.
|
||||
// The result of the operator is always a limited-precision integer, even if all arguments are literals.
|
||||
|
||||
a = (t ? 63 : 255) + (f ? 63 : 255);
|
||||
a = (t ? 0x3f : 0xff) + (f ? 0x3f : 0xff);
|
||||
a = (t ? uint8(63) : 255) + (f ? 63 : uint8(255));
|
||||
a = (t ? v63 : 255) + (f ? 63 : v255);
|
||||
|
||||
a = (true ? 63 : 255) + (false ? 63 : 255);
|
||||
a = (true ? 0x3f : 0xff) + (false ? 0x3f : 0xff);
|
||||
a = (true ? uint8(63) : 255) + (false ? 63 : uint8(255));
|
||||
a = (true ? v63 : 255) + (false ? 63 : v255);
|
||||
|
||||
a = (t ? 63 : 255) - (f ? 63 : 255);
|
||||
a = (t ? 63 : 255) * (f ? 63 : 255);
|
||||
a = (t ? 63 : 255) / (f ? 63 : 255);
|
||||
|
||||
a = (t ? (true ? 63 : 255) : (false ? 63 : 255)) + (f ? (t ? 63 : 255) : (f ? 63 : 255));
|
||||
a = uint8(t ? 63 : 255) + uint8(f ? 63 : 255);
|
||||
|
||||
}
|
||||
}
|
||||
// ----
|
||||
Reference in New Issue
Block a user