diff --git a/Changelog.md b/Changelog.md index 23145a61a..673098520 100644 --- a/Changelog.md +++ b/Changelog.md @@ -26,6 +26,7 @@ Bugfixes: * Standard JSON: Properly allow the ``inliner`` setting under ``settings.optimizer.details``. * Type Checker: Fix internal compiler error related to having mapping types in constructor parameter for abstract contracts. * Type Checker: Fix internal compiler error when attempting to use an invalid external function type on pre-byzantium EVMs. + * Type Checker: Make errors about (nested) mapping type in event or error parameter into fatal type errors. AST Changes: diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 113755650..1a9fb5e7e 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -3411,7 +3411,7 @@ void TypeChecker::checkErrorAndEventParameters(CallableDeclaration const& _calla for (ASTPointer const& var: _callable.parameters()) { if (type(*var)->containsNestedMapping()) - m_errorReporter.typeError( + m_errorReporter.fatalTypeError( 3448_error, var->location(), "Type containing a (nested) mapping is not allowed as " + kind + " parameter type." diff --git a/test/libsolidity/syntaxTests/errors/internal_type.sol b/test/libsolidity/syntaxTests/errors/internal_type.sol new file mode 100644 index 000000000..b88a27435 --- /dev/null +++ b/test/libsolidity/syntaxTests/errors/internal_type.sol @@ -0,0 +1,9 @@ +error E1(function() internal); +error E2(S); + +struct S { + S[] ss; +} +// ---- +// TypeError 3417: (9-29): Internal or recursive type is not allowed as error parameter type. +// TypeError 3417: (40-41): Internal or recursive type is not allowed as error parameter type. diff --git a/test/libsolidity/syntaxTests/errors/no_mappings.sol b/test/libsolidity/syntaxTests/errors/no_mappings.sol index 9a8c9e509..1de0e2374 100644 --- a/test/libsolidity/syntaxTests/errors/no_mappings.sol +++ b/test/libsolidity/syntaxTests/errors/no_mappings.sol @@ -4,6 +4,3 @@ contract C { } // ---- // TypeError 3448: (14-35): Type containing a (nested) mapping is not allowed as error parameter type. -// TypeError 3417: (14-35): Internal or recursive type is not allowed as error parameter type. -// TypeError 3448: (70-91): Type containing a (nested) mapping is not allowed as error parameter type. -// TypeError 3417: (70-91): Internal or recursive type is not allowed as error parameter type. diff --git a/test/libsolidity/syntaxTests/events/event_param_type_outside_storage.sol b/test/libsolidity/syntaxTests/events/event_param_type_outside_storage.sol index 483bfab21..3adc1bb7a 100644 --- a/test/libsolidity/syntaxTests/events/event_param_type_outside_storage.sol +++ b/test/libsolidity/syntaxTests/events/event_param_type_outside_storage.sol @@ -3,5 +3,3 @@ contract c { } // ---- // TypeError 3448: (41-72): Type containing a (nested) mapping is not allowed as event parameter type. -// TypeError 3417: (41-72): Internal or recursive type is not allowed as event parameter type. -// TypeError 8598: (17-132): More than 4 indexed arguments for anonymous event. diff --git a/test/libsolidity/syntaxTests/events/internal_type.sol b/test/libsolidity/syntaxTests/events/internal_type.sol new file mode 100644 index 000000000..1e584a8eb --- /dev/null +++ b/test/libsolidity/syntaxTests/events/internal_type.sol @@ -0,0 +1,11 @@ +struct S { + S[] ss; +} + +contract C { + event E1(function() internal); + event E2(S); +} +// ---- +// TypeError 3417: (52-72): Internal or recursive type is not allowed as event parameter type. +// TypeError 3417: (87-88): Internal or recursive type is not allowed as event parameter type. diff --git a/test/libsolidity/syntaxTests/types/mapping/error_parameter.sol b/test/libsolidity/syntaxTests/types/mapping/error_parameter.sol new file mode 100644 index 000000000..d836e7bf2 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/error_parameter.sol @@ -0,0 +1,3 @@ +error E (mapping (uint => uint)); +// ---- +// TypeError 3448: (9-31): Type containing a (nested) mapping is not allowed as error parameter type. diff --git a/test/libsolidity/syntaxTests/types/mapping/event_parameter.sol b/test/libsolidity/syntaxTests/types/mapping/event_parameter.sol new file mode 100644 index 000000000..c21d1b8e3 --- /dev/null +++ b/test/libsolidity/syntaxTests/types/mapping/event_parameter.sol @@ -0,0 +1,5 @@ +contract C { + event E (mapping (uint => uint) [2]); +} +// ---- +// TypeError 3448: (26-52): Type containing a (nested) mapping is not allowed as event parameter type.