diff --git a/Changelog.md b/Changelog.md index c70922942..ff183e22b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -23,6 +23,8 @@ Bugfixes: * Commandline Interface: When linking only accept exact matches for library names passed to the ``--libraries`` option. Library names not prefixed with a file name used to match any library with that name. * SMTChecker: Fix internal error in magic type access (``block``, ``msg``, ``tx``). * TypeChecker: Fix internal error when using user defined value types in public library functions. + * TypeChecker: Fix internal error when using arrays and structs with user defined value types before declaration. + * TypeChecker: Improved error message for constant variables with (nested) mapping types. * Yul Assembler: Fix internal error when function names are not unique. * Yul IR Generator: Do not output empty switches/if-bodies for empty contracts. diff --git a/libsolidity/analysis/DeclarationTypeChecker.cpp b/libsolidity/analysis/DeclarationTypeChecker.cpp index b015939e2..d531fd77f 100644 --- a/libsolidity/analysis/DeclarationTypeChecker.cpp +++ b/libsolidity/analysis/DeclarationTypeChecker.cpp @@ -289,7 +289,6 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName) return; } - solAssert(baseType->storageBytes() != 0, "Illegal base type of storage size zero for array."); if (Expression const* length = _typeName.length()) { optional lengthValue; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index f11756b25..0b5f97719 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1220,6 +1220,14 @@ void TypeChecker::endVisit(RevertStatement const& _revert) m_errorReporter.typeError(1885_error, errorCall.expression().location(), "Expression has to be an error."); } +void TypeChecker::endVisit(ArrayTypeName const& _typeName) +{ + solAssert( + _typeName.baseType().annotation().type && + _typeName.baseType().annotation().type->storageBytes() != 0, + "Illegal base type of storage size zero for array." + ); +} bool TypeChecker::visit(VariableDeclarationStatement const& _statement) { diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index bf5039204..f0820d930 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -119,6 +119,7 @@ private: void endVisit(InheritanceSpecifier const& _inheritance) override; void endVisit(ModifierDefinition const& _modifier) override; bool visit(FunctionDefinition const& _function) override; + void endVisit(ArrayTypeName const& _typeName) override; bool visit(VariableDeclaration const& _variable) override; /// We need to do this manually because we want to pass the bases of the current contract in /// case this is a base constructor call. diff --git a/test/libsolidity/syntaxTests/userDefinedValueType/forward_reference_array.sol b/test/libsolidity/syntaxTests/userDefinedValueType/forward_reference_array.sol new file mode 100644 index 000000000..884fb2b5d --- /dev/null +++ b/test/libsolidity/syntaxTests/userDefinedValueType/forward_reference_array.sol @@ -0,0 +1,4 @@ +contract C { + Left[] pu1; +} +type Left is bytes2;