Merge pull request #11939 from ethereum/userdefined-types-mapping-key

Allow Mapping keys to have type UserDefinedValueType.
This commit is contained in:
Harikrishnan Mulackal
2021-09-13 15:06:14 +02:00
committed by GitHub
9 changed files with 158 additions and 16 deletions
@@ -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