mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11939 from ethereum/userdefined-types-mapping-key
Allow Mapping keys to have type UserDefinedValueType.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
type MyInt is int;
|
||||
contract C {
|
||||
mapping(MyInt => int) public m;
|
||||
function set(MyInt key, int value) external {
|
||||
m[key] = value;
|
||||
}
|
||||
function set_unwrapped(int key, int value) external {
|
||||
m[MyInt.wrap(key)] = value;
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// set(int256,int256): 1, 1 ->
|
||||
// m(int256): 1 -> 1
|
||||
// set_unwrapped(int256,int256): 1, 2 ->
|
||||
// m(int256): 1 -> 2
|
||||
// m(int256): 2 -> 0
|
||||
Reference in New Issue
Block a user