mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for assembly access of user defined value types.
This commit is contained in:
parent
ee0e3e9377
commit
41f9aab219
@ -0,0 +1,35 @@
|
||||
pragma abicoder v1;
|
||||
|
||||
type MyBytes2 is bytes2;
|
||||
|
||||
contract C {
|
||||
function f(MyBytes2 val) external returns (bytes2 ret) {
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
}
|
||||
|
||||
function g(bytes2 val) external returns (bytes2 ret) {
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
}
|
||||
|
||||
function h(uint256 val) external returns (MyBytes2) {
|
||||
MyBytes2 ret;
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: false
|
||||
// ----
|
||||
// f(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// g(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// f(bytes2): "abcdef" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// g(bytes2): "abcdef" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// h(uint256): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// h(uint256): "abcdef" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
@ -0,0 +1,35 @@
|
||||
pragma abicoder v2;
|
||||
|
||||
type MyBytes2 is bytes2;
|
||||
|
||||
contract C {
|
||||
function f(MyBytes2 val) external returns (bytes2 ret) {
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
}
|
||||
|
||||
function g(bytes2 val) external returns (bytes2 ret) {
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
}
|
||||
|
||||
function h(uint256 val) external returns (MyBytes2) {
|
||||
MyBytes2 ret;
|
||||
assembly {
|
||||
ret := val
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// g(bytes2): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// f(bytes2): "abcdef" -> FAILURE
|
||||
// g(bytes2): "abcdef" -> FAILURE
|
||||
// h(uint256): "ab" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||
// h(uint256): "abcdef" -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
Loading…
Reference in New Issue
Block a user