Merge pull request #12361 from mejsiej/improved-err-msg-when-getter-returns-nothing

Changed the message of the error thrown when the structure has all it's members omitted
This commit is contained in:
chriseth 2021-12-20 21:06:14 +01:00 committed by GitHub
commit a4b2fc9cb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -592,7 +592,14 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
);
}
if (!getter.interfaceFunctionType())
m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables.");
{
solAssert(getter.returnParameterNames().size() == getter.returnParameterTypes().size());
solAssert(getter.parameterNames().size() == getter.parameterTypes().size());
if (getter.returnParameterTypes().empty() && getter.parameterTypes().empty())
m_errorReporter.typeError(5359_error, _variable.location(), "The struct has all its members omitted, therefore the getter cannot return any values.");
else
m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables.");
}
}
bool isStructMemberDeclaration = dynamic_cast<StructDefinition const*>(_variable.scope()) != nullptr;

View File

@ -3,4 +3,4 @@ contract test {
Data public data;
}
// ----
// TypeError 6744: (58-74): Internal or recursive type is not allowed for public state variables.
// TypeError 5359: (58-74): The struct has all its members omitted, therefore the getter cannot return any values.