mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use state mutability in override error messages
This commit is contained in:
parent
a2aaa47ee2
commit
a61c88e9fe
@ -318,17 +318,16 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
|
|||||||
if (function.visibility() != super.visibility())
|
if (function.visibility() != super.visibility())
|
||||||
overrideError(function, super, "Overriding function visibility differs.");
|
overrideError(function, super, "Overriding function visibility differs.");
|
||||||
|
|
||||||
else if (function.isDeclaredConst() && !super.isDeclaredConst())
|
else if (function.stateMutability() != super.stateMutability())
|
||||||
overrideError(function, super, "Overriding function should not be declared constant.");
|
overrideError(
|
||||||
|
function,
|
||||||
else if (!function.isDeclaredConst() && super.isDeclaredConst())
|
super,
|
||||||
overrideError(function, super, "Overriding function should be declared constant.");
|
"Overriding function changes state mutability from \"" +
|
||||||
|
stateMutabilityToString(super.stateMutability()) +
|
||||||
else if (function.isPayable() && !super.isPayable())
|
"\" to \"" +
|
||||||
overrideError(function, super, "Overriding function should not be declared payable.");
|
stateMutabilityToString(function.stateMutability()) +
|
||||||
|
"\"."
|
||||||
else if (!function.isPayable() && super.isPayable())
|
);
|
||||||
overrideError(function, super, "Overriding function should be declared payable.");
|
|
||||||
|
|
||||||
else if (functionType != superType)
|
else if (functionType != superType)
|
||||||
overrideError(function, super, "Overriding function return types differ.");
|
overrideError(function, super, "Overriding function return types differ.");
|
||||||
|
@ -933,7 +933,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_remove_constness)
|
|||||||
contract B { function f() constant {} }
|
contract B { function f() constant {} }
|
||||||
contract C is B { function f() {} }
|
contract C is B { function f() {} }
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Overriding function should be declared constant.");
|
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"view\" to \"nonpayable\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(illegal_override_add_constness)
|
BOOST_AUTO_TEST_CASE(illegal_override_add_constness)
|
||||||
@ -942,7 +942,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_add_constness)
|
|||||||
contract B { function f() {} }
|
contract B { function f() {} }
|
||||||
contract C is B { function f() constant {} }
|
contract C is B { function f() constant {} }
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Overriding function should not be declared constant.");
|
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"nonpayable\" to \"view\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(complex_inheritance)
|
BOOST_AUTO_TEST_CASE(complex_inheritance)
|
||||||
@ -4779,7 +4779,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable)
|
|||||||
contract B { function f() payable {} }
|
contract B { function f() payable {} }
|
||||||
contract C is B { function f() {} }
|
contract C is B { function f() {} }
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Overriding function should be declared payable.");
|
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"payable\" to \"nonpayable\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
|
BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
|
||||||
@ -4788,7 +4788,7 @@ BOOST_AUTO_TEST_CASE(illegal_override_payable_nonpayable)
|
|||||||
contract B { function f() {} }
|
contract B { function f() {} }
|
||||||
contract C is B { function f() payable {} }
|
contract C is B { function f() payable {} }
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Overriding function should not be declared payable.");
|
CHECK_ERROR(text, TypeError, "Overriding function changes state mutability from \"nonpayable\" to \"payable\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(function_variable_mixin)
|
BOOST_AUTO_TEST_CASE(function_variable_mixin)
|
||||||
|
Loading…
Reference in New Issue
Block a user