diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 717fa043b..efbbc5741 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2847,7 +2847,11 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) } default: - m_errorReporter.fatalTypeError(5704_error, _functionCall.location(), "Type is not callable"); + m_errorReporter.fatalTypeError( + 5704_error, + _functionCall.location(), + capitalized(Type::categoryName(expressionType->category())) + " is not callable." + ); // Unreachable, because fatalTypeError throws. We don't set kind, but that's okay because the switch below // is never reached. And, even if it was, SetOnce would trigger an assertion violation and not UB. funcCallAnno.isPure = argumentsArePure; diff --git a/test/libsolidity/syntaxTests/functionCalls/enum_value_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/enum_value_not_callable.sol new file mode 100644 index 000000000..0735f446f --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/enum_value_not_callable.sol @@ -0,0 +1,7 @@ +enum E { A, B, C } + +contract C { + uint a = E.B(1000); +} +// ---- +// TypeError 5704: (46-55): Enum is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol index 5c7260f36..5481ff1a3 100644 --- a/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol +++ b/test/libsolidity/syntaxTests/functionCalls/int_not_callable.sol @@ -5,4 +5,4 @@ contract C } } // ---- -// TypeError 5704: (53-60): Type is not callable +// TypeError 5704: (53-60): Rational number literal is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/magic_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/magic_not_callable.sol new file mode 100644 index 000000000..b74685d4b --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/magic_not_callable.sol @@ -0,0 +1,5 @@ +contract C { + uint a = msg(1000); +} +// ---- +// TypeError 5704: (26-35): Magic variable is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/mapping_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/mapping_not_callable.sol new file mode 100644 index 000000000..d06712999 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/mapping_not_callable.sol @@ -0,0 +1,6 @@ +contract C { + mapping (uint => uint) m; + uint a = m(1000); +} +// ---- +// TypeError 5704: (56-63): Mapping is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/modifier_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/modifier_not_callable.sol new file mode 100644 index 000000000..31ef66fe1 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/modifier_not_callable.sol @@ -0,0 +1,7 @@ +contract C { + uint a = m(1000); + + modifier m(uint) { _; } +} +// ---- +// TypeError 5704: (26-33): Modifier is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/module_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/module_not_callable.sol new file mode 100644 index 000000000..63debdab7 --- /dev/null +++ b/test/libsolidity/syntaxTests/functionCalls/module_not_callable.sol @@ -0,0 +1,9 @@ +==== Source: A.sol ==== +==== Source: B.sol ==== +import "A.sol" as A; + +contract C { + uint a = A(1000); +} +// ---- +// TypeError 5704: (B.sol:48-55): Module is not callable. diff --git a/test/libsolidity/syntaxTests/functionCalls/this_not_callable.sol b/test/libsolidity/syntaxTests/functionCalls/this_not_callable.sol index 52e6986bb..35c04d473 100644 --- a/test/libsolidity/syntaxTests/functionCalls/this_not_callable.sol +++ b/test/libsolidity/syntaxTests/functionCalls/this_not_callable.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 5704: (72-78): Type is not callable +// TypeError 5704: (72-78): Contract is not callable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol index 05239fa1b..6c5539e3b 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/462_callable_crash.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 5704: (90-108): Type is not callable +// TypeError 5704: (90-108): Rational number literal is not callable. diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol index 392d02e9f..595785e93 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/492_do_not_crash_on_not_lvalue.sol @@ -6,4 +6,4 @@ contract C { } } // ---- -// TypeError 5704: (153-157): Type is not callable +// TypeError 5704: (153-157): Mapping is not callable. diff --git a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol index 049fca274..eeef3e7ea 100644 --- a/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol +++ b/test/libsolidity/syntaxTests/scoping/state_variable_function_conflict_former_crash.sol @@ -11,4 +11,4 @@ contract SomeContract { } // ---- // DeclarationError 2333: (106-145): Identifier already declared. -// TypeError 5704: (185-195): Type is not callable +// TypeError 5704: (185-195): Integer is not callable. diff --git a/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol index a251b3a9b..701af022b 100644 --- a/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol +++ b/test/libsolidity/syntaxTests/tupleAssignments/double_storage_crash.sol @@ -7,4 +7,4 @@ contract CrashContract { } } // ---- -// TypeError 5704: (170-177): Type is not callable +// TypeError 5704: (170-177): Rational number literal is not callable. diff --git a/test/libsolidity/syntaxTests/types/function_call_fail.sol b/test/libsolidity/syntaxTests/types/function_call_fail.sol index 7e2d0b230..042b78f01 100644 --- a/test/libsolidity/syntaxTests/types/function_call_fail.sol +++ b/test/libsolidity/syntaxTests/types/function_call_fail.sol @@ -4,4 +4,4 @@ contract C { } } // ---- -// TypeError 5704: (59-63): Type is not callable +// TypeError 5704: (59-63): Rational number literal is not callable.