Skip to content

Commit ddd9a84

Browse files
mejsiejchriseth
authored andcommitted
Improve failure message when generating getter.
1 parent 8da9239 commit ddd9a84

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

libsolidity/analysis/TypeChecker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,14 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
592592
);
593593
}
594594
if (!getter.interfaceFunctionType())
595-
m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables.");
595+
{
596+
solAssert(getter.returnParameterNames().size() == getter.returnParameterTypes().size());
597+
solAssert(getter.parameterNames().size() == getter.parameterTypes().size());
598+
if (getter.returnParameterTypes().empty() && getter.parameterTypes().empty())
599+
m_errorReporter.typeError(5359_error, _variable.location(), "The struct has all its members omitted, therefore the getter cannot return any values.");
600+
else
601+
m_errorReporter.typeError(6744_error, _variable.location(), "Internal or recursive type is not allowed for public state variables.");
602+
}
596603
}
597604

598605
bool isStructMemberDeclaration = dynamic_cast<StructDefinition const*>(_variable.scope()) != nullptr;

test/libsolidity/syntaxTests/nameAndTypeResolution/070_struct_accessor_one_array_only.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ contract test {
33
Data public data;
44
}
55
// ----
6-
// TypeError 6744: (58-74): Internal or recursive type is not allowed for public state variables.
6+
// TypeError 5359: (58-74): The struct has all its members omitted, therefore the getter cannot return any values.

0 commit comments

Comments
 (0)