mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Sol -> Yul: Implement explicit cast
This commit is contained in:
committed by
chriseth
parent
441369d5f1
commit
1ef213cc15
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f() public pure returns (uint16 x) {
|
||||
uint8 y = uint8(0x12345678);
|
||||
x = y;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f() -> 0x78
|
||||
@@ -0,0 +1,12 @@
|
||||
contract C {
|
||||
function f(bytes32 b) public pure returns (bytes32 x) {
|
||||
x = b;
|
||||
}
|
||||
function g() public pure returns (bytes32 x) {
|
||||
x = f(bytes4(uint32(0x12345678)));
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// g() -> 0x1234567800000000000000000000000000000000000000000000000000000000
|
||||
@@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
function f(uint a) public pure returns (uint8 x) {
|
||||
uint8 b = uint8(a);
|
||||
x = b;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: true
|
||||
// ----
|
||||
// f(uint256): 0x12345678 -> 0x78
|
||||
Reference in New Issue
Block a user