Skip to content

Commit 34da6c8

Browse files
committed
Remove the inaccurate Type::categoryName() and change the error message for invalid calls to one independent of the category
1 parent a77d4e2 commit 34da6c8

16 files changed

+13
-57
lines changed

libsolidity/analysis/TypeChecker.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -2847,11 +2847,7 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
28472847
}
28482848

28492849
default:
2850-
m_errorReporter.fatalTypeError(
2851-
5704_error,
2852-
_functionCall.location(),
2853-
capitalized(Type::categoryName(expressionType->category())) + " is not callable."
2854-
);
2850+
m_errorReporter.fatalTypeError(5704_error, _functionCall.location(), "This expression is not callable.");
28552851
// Unreachable, because fatalTypeError throws. We don't set kind, but that's okay because the switch below
28562852
// is never reached. And, even if it was, SetOnce would trigger an assertion violation and not UB.
28572853
funcCallAnno.isPure = argumentsArePure;

libsolidity/ast/Types.cpp

-29
Original file line numberDiff line numberDiff line change
@@ -294,35 +294,6 @@ Type const* Type::commonType(Type const* _a, Type const* _b)
294294
return nullptr;
295295
}
296296

297-
char const* Type::categoryName(Type::Category _category)
298-
{
299-
switch (_category)
300-
{
301-
case Category::Address: return "address";
302-
case Category::Integer: return "integer";
303-
case Category::RationalNumber: return "rational number literal";
304-
case Category::StringLiteral: return "string literal";
305-
case Category::Bool: return "boolean";
306-
case Category::FixedPoint: return "fixed-point number";
307-
case Category::Array: return "array";
308-
case Category::ArraySlice: return "array slice";
309-
case Category::FixedBytes: return "fixed-size byte array";
310-
case Category::Contract: return "contract";
311-
case Category::Struct: return "struct";
312-
case Category::Function: return "function";
313-
case Category::Enum: return "enum";
314-
case Category::UserDefinedValueType: return "user-defined value type";
315-
case Category::Tuple: return "tuple";
316-
case Category::Mapping: return "mapping";
317-
case Category::TypeType: return "type of a type";
318-
case Category::Modifier: return "modifier";
319-
case Category::Magic: return "magic variable";
320-
case Category::Module: return "module";
321-
case Category::InaccessibleDynamic: return "inaccessible dynamic value";
322-
}
323-
util::unreachable();
324-
}
325-
326297
MemberList const& Type::members(ASTNode const* _currentScope) const
327298
{
328299
if (!m_members[_currentScope])

libsolidity/ast/Types.h

-2
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ class Type
201201
static Type const* commonType(Type const* _a, Type const* _b);
202202

203203
virtual Category category() const = 0;
204-
static char const* categoryName(Type::Category _category);
205-
206204
/// @returns a valid solidity identifier such that two types should compare equal if and
207205
/// only if they have the same identifier.
208206
/// The identifier should start with "t_".

libsolutil/StringUtils.h

-9
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,6 @@ inline std::string toLower(std::string _s)
160160
return _s;
161161
}
162162

163-
/// Returns a copy of the string with the first character converted to its uppercase equivalent.
164-
/// Uses the classic "C" locale semantics.
165-
inline std::string capitalized(std::string _s)
166-
{
167-
if (_s.size() > 0)
168-
_s[0] = toUpper(_s[0]);
169-
return _s;
170-
}
171-
172163
/// Checks whether _c is a decimal digit character. It uses the classic "C" locale semantics.
173164
/// @param _c character to be checked
174165
/// @return true if _c is a decimal digit character, false otherwise

test/libsolidity/syntaxTests/functionCalls/enum_value_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract C {
44
uint a = E.B(1000);
55
}
66
// ----
7-
// TypeError 5704: (46-55): Enum is not callable.
7+
// TypeError 5704: (46-55): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ contract C
55
}
66
}
77
// ----
8-
// TypeError 5704: (53-60): Rational number literal is not callable.
8+
// TypeError 5704: (53-60): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/magic_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ contract C {
22
uint a = msg(1000);
33
}
44
// ----
5-
// TypeError 5704: (26-35): Magic variable is not callable.
5+
// TypeError 5704: (26-35): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/mapping_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ contract C {
33
uint a = m(1000);
44
}
55
// ----
6-
// TypeError 5704: (56-63): Mapping is not callable.
6+
// TypeError 5704: (56-63): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/modifier_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract C {
44
modifier m(uint) { _; }
55
}
66
// ----
7-
// TypeError 5704: (26-33): Modifier is not callable.
7+
// TypeError 5704: (26-33): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/module_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ contract C {
66
uint a = A(1000);
77
}
88
// ----
9-
// TypeError 5704: (B.sol:48-55): Module is not callable.
9+
// TypeError 5704: (B.sol:48-55): This expression is not callable.

test/libsolidity/syntaxTests/functionCalls/this_not_callable.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ contract C {
66
}
77
}
88
// ----
9-
// TypeError 5704: (72-78): Contract is not callable.
9+
// TypeError 5704: (72-78): This expression is not callable.

test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ contract C {
66
}
77
}
88
// ----
9-
// TypeError 5704: (90-108): Rational number literal is not callable.
9+
// TypeError 5704: (90-108): This expression is not callable.

test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ contract C {
66
}
77
}
88
// ----
9-
// TypeError 5704: (153-157): Mapping is not callable.
9+
// TypeError 5704: (153-157): This expression is not callable.

test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ contract SomeContract {
1111
}
1212
// ----
1313
// DeclarationError 2333: (106-145): Identifier already declared.
14-
// TypeError 5704: (185-195): Integer is not callable.
14+
// TypeError 5704: (185-195): This expression is not callable.

test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ contract CrashContract {
77
}
88
}
99
// ----
10-
// TypeError 5704: (170-177): Rational number literal is not callable.
10+
// TypeError 5704: (170-177): This expression is not callable.

test/libsolidity/syntaxTests/types/function_call_fail.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ contract C {
44
}
55
}
66
// ----
7-
// TypeError 5704: (59-63): Rational number literal is not callable.
7+
// TypeError 5704: (59-63): This expression is not callable.

0 commit comments

Comments
 (0)