Moved storage size assert to TypeChecker from DeclarationTypeChecker

This commit is contained in:
hrkrshnn 2021-10-25 11:58:49 +01:00
parent 453f404f8f
commit 9428dbc94f
5 changed files with 15 additions and 1 deletions

View File

@ -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. * 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``). * 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 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 Assembler: Fix internal error when function names are not unique.
* Yul IR Generator: Do not output empty switches/if-bodies for empty contracts. * Yul IR Generator: Do not output empty switches/if-bodies for empty contracts.

View File

@ -289,7 +289,6 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
return; return;
} }
solAssert(baseType->storageBytes() != 0, "Illegal base type of storage size zero for array.");
if (Expression const* length = _typeName.length()) if (Expression const* length = _typeName.length())
{ {
optional<rational> lengthValue; optional<rational> lengthValue;

View File

@ -1220,6 +1220,14 @@ void TypeChecker::endVisit(RevertStatement const& _revert)
m_errorReporter.typeError(1885_error, errorCall.expression().location(), "Expression has to be an error."); 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) bool TypeChecker::visit(VariableDeclarationStatement const& _statement)
{ {

View File

@ -119,6 +119,7 @@ private:
void endVisit(InheritanceSpecifier const& _inheritance) override; void endVisit(InheritanceSpecifier const& _inheritance) override;
void endVisit(ModifierDefinition const& _modifier) override; void endVisit(ModifierDefinition const& _modifier) override;
bool visit(FunctionDefinition const& _function) override; bool visit(FunctionDefinition const& _function) override;
void endVisit(ArrayTypeName const& _typeName) override;
bool visit(VariableDeclaration const& _variable) 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 /// 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. /// case this is a base constructor call.

View File

@ -0,0 +1,4 @@
contract C {
Left[] pu1;
}
type Left is bytes2;