Improve failure message when generating getter.

This commit is contained in:
mejsiej 2021-12-02 12:36:04 +01:00 committed by chriseth
parent 8da9239c83
commit ddd9a84141
2 changed files with 9 additions and 2 deletions

View File

@ -592,7 +592,14 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
); );
} }
if (!getter.interfaceFunctionType()) 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; bool isStructMemberDeclaration = dynamic_cast<StructDefinition const*>(_variable.scope()) != nullptr;

View File

@ -3,4 +3,4 @@ contract test {
Data public data; 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.