Update "using for" directive type checking

This commit is contained in:
wechman
2022-09-28 13:07:59 +02:00
parent acf4557c41
commit eefb107e4d
6 changed files with 50 additions and 14 deletions
@@ -1,3 +1,5 @@
pragma abicoder v2;
using {
addC as +,
addM as +,
@@ -0,0 +1,21 @@
using {add as +} for S;
struct S {
int v;
}
function add(S storage _a, S storage) returns (S memory) {
_a.v = 7;
return _a;
}
contract C {
S s;
function f() public returns (S memory) {
return s + s;
}
}
// ----
// TypeError 3605: (7-10): The function "add" needs to have parameters and return value of the same type to be used for the operator +.
@@ -28,6 +28,7 @@ function f() pure {
// TypeError 1884: (33-36): The function "add" needs to have two parameters of type Int and the same data location to be used for the operator +.
// TypeError 8112: (47-50): The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -.
// TypeError 7617: (61-64): The function "div" needs to have one or two parameters of type Int and the same data location to be used for the operator /.
// TypeError 3605: (61-64): The function "div" needs to have parameters and return value of the same type to be used for the operator /.
// TypeError 2271: (325-350): Operator + not compatible with types Int and Int. No matching user-defined operator found.
// TypeError 2271: (356-381): Operator - not compatible with types Int and Int. No matching user-defined operator found.
// TypeError 2271: (387-412): Operator / not compatible with types Int and Int. No matching user-defined operator found.
@@ -62,6 +62,7 @@ function test(S calldata s) pure {
// TypeError 7743: (54-57): The function "div" needs to return exactly one value of type S to be used for the operator /.
// TypeError 7743: (68-71): The function "mod" needs to return exactly one value of type S to be used for the operator %.
// TypeError 7617: (82-87): The function "unsub" needs to have one or two parameters of type S and the same data location to be used for the operator -.
// TypeError 3605: (82-87): The function "unsub" needs to have parameters and return value of the same type to be used for the operator -.
// TypeError 7743: (98-104): The function "bitnot" needs to return exactly one value of type S to be used for the operator ~.
// TypeError 2271: (758-763): Operator * not compatible with types struct S calldata and struct S calldata. No matching user-defined operator found.
// TypeError 4907: (791-793): Unary operator - cannot be applied to type struct S calldata. No matching user-defined operator found.
@@ -38,4 +38,6 @@ function bitor(S storage, S storage) pure returns (S memory) {
// TypeError 7617: (71-74): The function "sub" needs to have one or two parameters of type Int and the same data location to be used for the operator -.
// TypeError 7743: (71-74): The function "sub" needs to return exactly one value of type Int to be used for the operator -.
// TypeError 1884: (85-88): The function "mul" needs to have two parameters of type Int and the same data location to be used for the operator *.
// TypeError 3605: (85-88): The function "mul" needs to have parameters and return value of the same type to be used for the operator *.
// TypeError 7743: (95-98): The function "div" needs to return exactly one value of type Int to be used for the operator /.
// TypeError 3605: (128-133): The function "bitor" needs to have parameters and return value of the same type to be used for the operator |.