Skip to content

Commit 6da09e8

Browse files
wechmancameel
authored andcommitted
Error message tweak: built-in unary/binary operator
1 parent 4c9a58e commit 6da09e8

File tree

63 files changed

+172
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+172
-172
lines changed

libsolidity/analysis/TypeChecker.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ bool TypeChecker::visit(UnaryOperation const& _operation)
17311731
TypeResult result = type(_operation.subExpression())->unaryOperatorResult(op);
17321732
if (!result)
17331733
{
1734-
string description = "Unary operator " + string(TokenTraits::toString(op)) + " cannot be applied to type " + subExprType->humanReadableName() + "." + (!result.message().empty() ? " " + result.message() : "");
1734+
string description = "Built-in unary operator " + string(TokenTraits::toString(op)) + " cannot be applied to type " + subExprType->humanReadableName() + "." + (!result.message().empty() ? " " + result.message() : "");
17351735
if (modifying)
17361736
// Cannot just report the error, ignore the unary operator, and continue,
17371737
// because the sub-expression was already processed with requireLValue()
@@ -1760,9 +1760,9 @@ void TypeChecker::endVisit(BinaryOperation const& _operation)
17601760
m_errorReporter.typeError(
17611761
2271_error,
17621762
_operation.location(),
1763-
"Operator " +
1763+
"Built-in binary operator " +
17641764
string(TokenTraits::toString(_operation.getOperator())) +
1765-
" not compatible with types " +
1765+
" cannot be applied to types " +
17661766
leftType->humanReadableName() +
17671767
" and " +
17681768
rightType->humanReadableName() + "." +

test/libsolidity/syntaxTests/abiEncoder/abi_encodeCall_tuple_from_invalid_operator.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ contract C {
1515
}
1616
}
1717
// ----
18-
// TypeError 2271: (284-299): Operator + not compatible with types tuple(int_const 1,int_const 1) and tuple(int_const 2,int_const 2).
18+
// TypeError 2271: (284-299): Built-in binary operator + cannot be applied to types tuple(int_const 1,int_const 1) and tuple(int_const 2,int_const 2).
1919
// TypeError 9062: (284-299): Expected an inline tuple, not an expression of a tuple type.
20-
// TypeError 2271: (334-345): Operator / not compatible with types tuple() and tuple().
20+
// TypeError 2271: (334-345): Built-in binary operator / cannot be applied to types tuple() and tuple().
2121
// TypeError 9062: (334-345): Expected an inline tuple, not an expression of a tuple type.
22-
// TypeError 4907: (380-383): Unary operator ! cannot be applied to type tuple().
22+
// TypeError 4907: (380-383): Built-in unary operator ! cannot be applied to type tuple().
2323
// TypeError 9062: (380-383): Expected an inline tuple, not an expression of a tuple type.

test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_comparison.sol

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ contract C {
1919
}
2020
}
2121
// ----
22-
// TypeError 2271: (144-157): Operator != not compatible with types type(contract super C) and contract C.
23-
// TypeError 2271: (167-180): Operator != not compatible with types contract C and type(contract super C).
24-
// TypeError 2271: (254-264): Operator != not compatible with types type(contract super C) and contract C.
25-
// TypeError 2271: (274-284): Operator != not compatible with types contract C and type(contract super C).
26-
// TypeError 2271: (349-359): Operator != not compatible with types type(contract super C) and contract D.
27-
// TypeError 2271: (369-379): Operator != not compatible with types contract D and type(contract super C).
22+
// TypeError 2271: (144-157): Built-in binary operator != cannot be applied to types type(contract super C) and contract C.
23+
// TypeError 2271: (167-180): Built-in binary operator != cannot be applied to types contract C and type(contract super C).
24+
// TypeError 2271: (254-264): Built-in binary operator != cannot be applied to types type(contract super C) and contract C.
25+
// TypeError 2271: (274-284): Built-in binary operator != cannot be applied to types contract C and type(contract super C).
26+
// TypeError 2271: (349-359): Built-in binary operator != cannot be applied to types type(contract super C) and contract D.
27+
// TypeError 2271: (369-379): Built-in binary operator != cannot be applied to types contract D and type(contract super C).

test/libsolidity/syntaxTests/conversion/implicit_conversion_of_super_in_operators.sol

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ contract C {
3030
}
3131
}
3232
// ----
33-
// TypeError 2271: (49-62): Operator << not compatible with types type(contract super C) and contract C.
34-
// TypeError 2271: (72-85): Operator >> not compatible with types type(contract super C) and contract C.
35-
// TypeError 2271: (95-107): Operator ^ not compatible with types type(contract super C) and contract C.
36-
// TypeError 2271: (117-129): Operator | not compatible with types type(contract super C) and contract C.
37-
// TypeError 2271: (139-151): Operator & not compatible with types type(contract super C) and contract C.
38-
// TypeError 2271: (162-174): Operator * not compatible with types type(contract super C) and contract C.
39-
// TypeError 2271: (184-196): Operator / not compatible with types type(contract super C) and contract C.
40-
// TypeError 2271: (206-218): Operator % not compatible with types type(contract super C) and contract C.
41-
// TypeError 2271: (228-240): Operator - not compatible with types type(contract super C) and contract C.
42-
// TypeError 2271: (250-262): Operator + not compatible with types type(contract super C) and contract C.
43-
// TypeError 2271: (272-285): Operator ** not compatible with types type(contract super C) and contract C.
44-
// TypeError 2271: (296-309): Operator == not compatible with types type(contract super C) and contract C.
45-
// TypeError 2271: (319-332): Operator != not compatible with types type(contract super C) and contract C.
46-
// TypeError 2271: (342-355): Operator >= not compatible with types type(contract super C) and contract C.
47-
// TypeError 2271: (365-378): Operator <= not compatible with types type(contract super C) and contract C.
48-
// TypeError 2271: (388-400): Operator < not compatible with types type(contract super C) and contract C.
49-
// TypeError 2271: (410-422): Operator > not compatible with types type(contract super C) and contract C.
50-
// TypeError 2271: (433-446): Operator || not compatible with types type(contract super C) and contract C.
51-
// TypeError 2271: (456-469): Operator && not compatible with types type(contract super C) and contract C.
33+
// TypeError 2271: (49-62): Built-in binary operator << cannot be applied to types type(contract super C) and contract C.
34+
// TypeError 2271: (72-85): Built-in binary operator >> cannot be applied to types type(contract super C) and contract C.
35+
// TypeError 2271: (95-107): Built-in binary operator ^ cannot be applied to types type(contract super C) and contract C.
36+
// TypeError 2271: (117-129): Built-in binary operator | cannot be applied to types type(contract super C) and contract C.
37+
// TypeError 2271: (139-151): Built-in binary operator & cannot be applied to types type(contract super C) and contract C.
38+
// TypeError 2271: (162-174): Built-in binary operator * cannot be applied to types type(contract super C) and contract C.
39+
// TypeError 2271: (184-196): Built-in binary operator / cannot be applied to types type(contract super C) and contract C.
40+
// TypeError 2271: (206-218): Built-in binary operator % cannot be applied to types type(contract super C) and contract C.
41+
// TypeError 2271: (228-240): Built-in binary operator - cannot be applied to types type(contract super C) and contract C.
42+
// TypeError 2271: (250-262): Built-in binary operator + cannot be applied to types type(contract super C) and contract C.
43+
// TypeError 2271: (272-285): Built-in binary operator ** cannot be applied to types type(contract super C) and contract C.
44+
// TypeError 2271: (296-309): Built-in binary operator == cannot be applied to types type(contract super C) and contract C.
45+
// TypeError 2271: (319-332): Built-in binary operator != cannot be applied to types type(contract super C) and contract C.
46+
// TypeError 2271: (342-355): Built-in binary operator >= cannot be applied to types type(contract super C) and contract C.
47+
// TypeError 2271: (365-378): Built-in binary operator <= cannot be applied to types type(contract super C) and contract C.
48+
// TypeError 2271: (388-400): Built-in binary operator < cannot be applied to types type(contract super C) and contract C.
49+
// TypeError 2271: (410-422): Built-in binary operator > cannot be applied to types type(contract super C) and contract C.
50+
// TypeError 2271: (433-446): Built-in binary operator || cannot be applied to types type(contract super C) and contract C.
51+
// TypeError 2271: (456-469): Built-in binary operator && cannot be applied to types type(contract super C) and contract C.
5252
// TypeError 4247: (480-485): Expression has to be an lvalue.
5353
// TypeError 7366: (480-493): Operator -= not compatible with types type(contract super C) and contract C.
5454
// TypeError 4247: (503-508): Expression has to be an lvalue.

test/libsolidity/syntaxTests/errors/error_incompatible_binary_ops.sol

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,21 @@ contract C {
2727
}
2828

2929
// ----
30-
// TypeError 2271: (86-116): Operator << not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
31-
// TypeError 2271: (126-156): Operator >> not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
32-
// TypeError 2271: (166-195): Operator ^ not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
33-
// TypeError 2271: (205-234): Operator | not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
34-
// TypeError 2271: (244-273): Operator & not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
35-
// TypeError 2271: (284-313): Operator * not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
36-
// TypeError 2271: (323-352): Operator / not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
37-
// TypeError 2271: (362-391): Operator % not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
38-
// TypeError 2271: (401-430): Operator + not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
39-
// TypeError 2271: (440-469): Operator - not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
40-
// TypeError 2271: (480-510): Operator == not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
41-
// TypeError 2271: (520-550): Operator != not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
42-
// TypeError 2271: (560-590): Operator >= not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
43-
// TypeError 2271: (600-630): Operator <= not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
44-
// TypeError 2271: (640-669): Operator < not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
45-
// TypeError 2271: (679-708): Operator > not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
46-
// TypeError 2271: (719-749): Operator || not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
47-
// TypeError 2271: (759-789): Operator && not compatible with types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
30+
// TypeError 2271: (86-116): Built-in binary operator << cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
31+
// TypeError 2271: (126-156): Built-in binary operator >> cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
32+
// TypeError 2271: (166-195): Built-in binary operator ^ cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
33+
// TypeError 2271: (205-234): Built-in binary operator | cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
34+
// TypeError 2271: (244-273): Built-in binary operator & cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
35+
// TypeError 2271: (284-313): Built-in binary operator * cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
36+
// TypeError 2271: (323-352): Built-in binary operator / cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
37+
// TypeError 2271: (362-391): Built-in binary operator % cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
38+
// TypeError 2271: (401-430): Built-in binary operator + cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
39+
// TypeError 2271: (440-469): Built-in binary operator - cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
40+
// TypeError 2271: (480-510): Built-in binary operator == cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
41+
// TypeError 2271: (520-550): Built-in binary operator != cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
42+
// TypeError 2271: (560-590): Built-in binary operator >= cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
43+
// TypeError 2271: (600-630): Built-in binary operator <= cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
44+
// TypeError 2271: (640-669): Built-in binary operator < cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
45+
// TypeError 2271: (679-708): Built-in binary operator > cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
46+
// TypeError 2271: (719-749): Built-in binary operator || cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).
47+
// TypeError 2271: (759-789): Built-in binary operator && cannot be applied to types error MyCustomError(uint256,bool) and error MyCustomError(uint256,bool).

test/libsolidity/syntaxTests/errors/error_incompatible_unary_operator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ contract C {
88

99
// ----
1010
// TypeError 4247: (86-99): Expression has to be an lvalue.
11-
// TypeError 9767: (86-101): Unary operator ++ cannot be applied to type error MyCustomError(uint256,bool).
11+
// TypeError 9767: (86-101): Built-in unary operator ++ cannot be applied to type error MyCustomError(uint256,bool).

test/libsolidity/syntaxTests/events/event_incompatible_binary_ops.sol

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ contract C {
2626
}
2727

2828
// ----
29-
// TypeError 2271: (83-113): Operator << not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
30-
// TypeError 2271: (123-153): Operator >> not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
31-
// TypeError 2271: (163-192): Operator ^ not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
32-
// TypeError 2271: (202-231): Operator | not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
33-
// TypeError 2271: (241-270): Operator & not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
34-
// TypeError 2271: (281-310): Operator * not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
35-
// TypeError 2271: (320-349): Operator / not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
36-
// TypeError 2271: (359-388): Operator % not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
37-
// TypeError 2271: (398-427): Operator + not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
38-
// TypeError 2271: (437-466): Operator - not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
39-
// TypeError 2271: (477-507): Operator == not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
40-
// TypeError 2271: (517-547): Operator != not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
41-
// TypeError 2271: (557-587): Operator >= not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
42-
// TypeError 2271: (597-627): Operator <= not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
43-
// TypeError 2271: (637-666): Operator < not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
44-
// TypeError 2271: (676-705): Operator > not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
45-
// TypeError 2271: (716-746): Operator || not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
46-
// TypeError 2271: (756-786): Operator && not compatible with types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
29+
// TypeError 2271: (83-113): Built-in binary operator << cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
30+
// TypeError 2271: (123-153): Built-in binary operator >> cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
31+
// TypeError 2271: (163-192): Built-in binary operator ^ cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
32+
// TypeError 2271: (202-231): Built-in binary operator | cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
33+
// TypeError 2271: (241-270): Built-in binary operator & cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
34+
// TypeError 2271: (281-310): Built-in binary operator * cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
35+
// TypeError 2271: (320-349): Built-in binary operator / cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
36+
// TypeError 2271: (359-388): Built-in binary operator % cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
37+
// TypeError 2271: (398-427): Built-in binary operator + cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
38+
// TypeError 2271: (437-466): Built-in binary operator - cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
39+
// TypeError 2271: (477-507): Built-in binary operator == cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
40+
// TypeError 2271: (517-547): Built-in binary operator != cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
41+
// TypeError 2271: (557-587): Built-in binary operator >= cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
42+
// TypeError 2271: (597-627): Built-in binary operator <= cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
43+
// TypeError 2271: (637-666): Built-in binary operator < cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
44+
// TypeError 2271: (676-705): Built-in binary operator > cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
45+
// TypeError 2271: (716-746): Built-in binary operator || cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).
46+
// TypeError 2271: (756-786): Built-in binary operator && cannot be applied to types event MyCustomEvent(uint256) and event MyCustomEvent(uint256).

test/libsolidity/syntaxTests/events/event_incompatible_unary_operator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ contract C {
77

88
// ----
99
// TypeError 4247: (83-96): Expression has to be an lvalue.
10-
// TypeError 9767: (83-98): Unary operator ++ cannot be applied to type event MyCustomEvent(uint256).
10+
// TypeError 9767: (83-98): Built-in unary operator ++ cannot be applied to type event MyCustomEvent(uint256).

test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_1.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract C {
44
}
55
}
66
// ----
7-
// TypeError 2271: (73-88): Operator > not compatible with types function () external returns (bool) and function () external returns (bool).
7+
// TypeError 2271: (73-88): Built-in binary operator > cannot be applied to types function () external returns (bool) and function () external returns (bool).

test/libsolidity/syntaxTests/functionTypes/comparison_of_function_types_gt_2.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract C {
44
}
55
}
66
// ----
7-
// TypeError 2271: (73-78): Operator > not compatible with types function () returns (bool) and function () returns (bool).
7+
// TypeError 2271: (73-78): Built-in binary operator > cannot be applied to types function () returns (bool) and function () returns (bool).

0 commit comments

Comments
 (0)