Update tests after code review

This commit is contained in:
wechman 2022-08-02 14:41:12 +02:00
parent c61d5b457e
commit c89eecf52b
6 changed files with 54 additions and 6 deletions

View File

@ -989,11 +989,16 @@ ASTPointer<UsingForDirective> Parser::parseUsingDirective()
Token::BitNot
};
if (!util::contains(overridable, operator_))
{
parserError(
4403_error,
("The operator " + string{TokenTraits::toString(operator_)} + " cannot be user-implemented. This is only possible for the following operators: ") +
(
"The operator " + (TokenTraits::toString(operator_) ? string(TokenTraits::toString(operator_)) + " " : "")
+ "cannot be user-implemented. This is only possible for the following operators: "
) +
util::joinHumanReadable(overridable | ranges::views::transform([](Token _t) { return string{TokenTraits::toString(_t)}; }))
);
}
operators.emplace_back(operator_);
advance();
}

View File

@ -0,0 +1,10 @@
using {add as +} for E;
error E();
function add(E, E) pure returns (E) {
return E.E1;
}
// ----
// TypeError 5172: (21-22): Name has to refer to a user-defined value type, struct, enum or contract.

View File

@ -1,10 +1,14 @@
using {
shiftL as <<, shiftR as >>,
exp as **, neg as !
shiftL as <<,
shiftR as >>,
exp as **,
neg as !,
f as x
} for int256;
// ----
// ParserError 4403: (22-24): The operator << cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (36-38): The operator >> cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (51-53): The operator ** cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (62-63): The operator ! cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (40-42): The operator >> cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (55-57): The operator ** cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (70-71): The operator ! cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~
// ParserError 4403: (82-83): The operator cannot be user-implemented. This is only possible for the following operators: |, &, ^, +, -, *, /, %, ==, !=, <, >, <=, >=, ~

View File

@ -0,0 +1,11 @@
using {add as +} for S;
struct S {
uint x;
}
function add(S calldata, S calldata) pure returns (S calldata r) {
assembly {
r := 0
}
}

View File

@ -0,0 +1,18 @@
using {add as +} for S;
struct S {
uint x;
}
function add(S storage a, S storage) pure returns (S storage) {
return a;
}
contract C {
S a;
S b;
function test() public view {
a + b;
}
}