mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10710 from ethereum/implicit-conversion-bug
Disallow certain implicit conversions between integer types.
This commit is contained in:
+3
-3
@@ -1,6 +1,6 @@
|
||||
contract test {
|
||||
function f() public { uint32(2) == int64(2); }
|
||||
function f() public { uint32(2) == uint64(2); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6133: (42-63): Statement has no effect.
|
||||
// Warning 2018: (20-66): Function state mutability can be restricted to pure
|
||||
// Warning 6133: (42-64): Statement has no effect.
|
||||
// Warning 2018: (20-67): Function state mutability can be restricted to pure
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
contract C
|
||||
{
|
||||
function f() public pure {
|
||||
uint16 a = 1;
|
||||
int32 b = a;
|
||||
|
||||
uint256 c = 10;
|
||||
int8 d = c;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9574: (74-85): Type uint16 is not implicitly convertible to expected type int32.
|
||||
// TypeError 9574: (120-130): Type uint256 is not implicitly convertible to expected type int8.
|
||||
@@ -37,6 +37,10 @@ contract C
|
||||
|
||||
B n = B(address(uint160(uint(int(100)))));
|
||||
n;
|
||||
|
||||
uint8 o = 1;
|
||||
int16 p = int16(o);
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError 9640: (801-809): Explicit type conversion not allowed from "uint8" to "int16".
|
||||
|
||||
Reference in New Issue
Block a user