Allow Mapping keys to have type UserDefinedValueType.

Also added syntax and semantic test.
This commit is contained in:
hrkrshnn
2021-09-13 10:03:49 +02:00
parent 952540c3b5
commit 1fa6c71bd0
6 changed files with 27 additions and 4 deletions
@@ -5,4 +5,4 @@ contract c {
mapping(S => uint) data;
}
// ----
// TypeError 7804: (47-48): Only elementary types, contract types or enums are allowed as mapping keys.
// TypeError 7804: (47-48): Only elementary types, user defined value types, contract types or enums are allowed as mapping keys.
@@ -5,4 +5,4 @@ contract c {
mapping(S => uint) data;
}
// ----
// TypeError 7804: (49-50): Only elementary types, contract types or enums are allowed as mapping keys.
// TypeError 7804: (49-50): Only elementary types, user defined value types, contract types or enums are allowed as mapping keys.
@@ -6,4 +6,4 @@ contract C {
function g (S calldata) external view {}
}
// ----
// TypeError 7804: (56-57): Only elementary types, contract types or enums are allowed as mapping keys.
// TypeError 7804: (56-57): Only elementary types, user defined value types, contract types or enums are allowed as mapping keys.
@@ -0,0 +1,4 @@
type MyInt is int;
contract C {
mapping(MyInt => int) m;
}