Natspec: Don't copy from base function if return parameters differ

This commit is contained in:
Mathias Baumann
2021-04-19 15:20:30 +02:00
parent 14d2170b46
commit 1737bd7ded
6 changed files with 109 additions and 9 deletions
+57 -1
View File
@@ -303,7 +303,11 @@ BOOST_AUTO_TEST_CASE(public_state_variable)
"state" :
{
"details" : "example of dev",
"return" : "returns state"
"return" : "returns state",
"returns" :
{
"_0" : "returns state"
}
}
}
}
@@ -2411,6 +2415,58 @@ BOOST_AUTO_TEST_CASE(custom_inheritance)
checkNatspec(sourceCode, "B", natspecB, false);
}
BOOST_AUTO_TEST_CASE(dev_different_amount_return_parameters)
{
char const *sourceCode = R"(
interface IThing {
/// @return x a number
/// @return y another number
function value() external view returns (uint128 x, uint128 y);
}
contract Thing is IThing {
struct Value {
uint128 x;
uint128 y;
}
Value public override value;
}
)";
char const *natspec = R"ABCDEF({
"methods":
{
"value()":
{
"returns":
{
"x": "a number",
"y": "another number"
}
}
}
})ABCDEF";
char const *natspec2 = R"ABCDEF({
"methods": {},
"stateVariables":
{
"value":
{
"returns":
{
"x": "a number",
"y": "another number"
}
}
}
})ABCDEF";
checkNatspec(sourceCode, "IThing", natspec, false);
checkNatspec(sourceCode, "Thing", natspec2, false);
}
}
BOOST_AUTO_TEST_SUITE_END()
@@ -0,0 +1,14 @@
interface IThing {
/// @return x a number
/// @return y another number
function value() external view returns (uint128 x, uint128 y);
}
contract Thing is IThing {
struct Value {
uint128 x;
uint128 y;
}
Value public override value;
}
@@ -0,0 +1,15 @@
interface IThing {
/// @param v value to search for
/// @return x a number
/// @return y another number
function value(uint256 v) external view returns (uint128 x, uint128 y);
}
contract Thing is IThing {
struct Value {
uint128 x;
uint128 y;
}
mapping(uint256=>Value) public override value;
}