diff --git a/Changelog.md b/Changelog.md index 95a8a25e0..61dec9c7d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,6 +4,10 @@ Compiler Features: * SMTChecker: Support ``addmod`` and ``mulmod``. +Bugfixes: + * Type Checker: Fix internal compiler error when calling `.push()` for a storage array with a nested mapping. + + ### 0.7.2 (2020-09-28) Important Bugfixes: diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 44edd0c8d..eb2e81743 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2684,10 +2684,20 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess) "Using \"." + memberName + "(...)\" is deprecated. Use \"{" + memberName + ": ...}\" instead." ); + if ( + funType->kind() == FunctionType::Kind::ArrayPush && + arguments.value().numArguments() != 0 && + exprType->containsNestedMapping() + ) + m_errorReporter.typeError( + 8871_error, + _memberAccess.location(), + "Storage arrays with nested mappings do not support .push()." + ); + if (!funType->bound()) if (auto contractType = dynamic_cast(exprType)) requiredLookup = contractType->isSuper() ? VirtualLookup::Super : VirtualLookup::Virtual; - } annotation.requiredLookup = requiredLookup; diff --git a/test/libsolidity/syntaxTests/array/pop/storage_with_mapping_pop.sol b/test/libsolidity/syntaxTests/array/pop/storage_with_mapping_pop.sol new file mode 100644 index 000000000..235ce3ba1 --- /dev/null +++ b/test/libsolidity/syntaxTests/array/pop/storage_with_mapping_pop.sol @@ -0,0 +1,7 @@ +contract C { + mapping(uint=>uint)[] array; + mapping(uint=>uint) map; + function f() public { + array.pop(); + } +} diff --git a/test/libsolidity/syntaxTests/array/push/storage_with_mapping_push.sol b/test/libsolidity/syntaxTests/array/push/storage_with_mapping_push.sol new file mode 100644 index 000000000..6032b0c2a --- /dev/null +++ b/test/libsolidity/syntaxTests/array/push/storage_with_mapping_push.sol @@ -0,0 +1,10 @@ +contract C { + mapping(uint=>uint)[] array; + mapping(uint=>uint) map; + function f() public { + array.push(); + array.push(map); + } +} +// ---- +// TypeError 8871: (131-141): Storage arrays with nested mappings do not support .push().