mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use a secondary location for function override errors
This commit is contained in:
parent
a6949851f3
commit
d4997dd9a3
@ -306,40 +306,31 @@ void TypeChecker::checkFunctionOverride(FunctionDefinition const& function, Func
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (function.visibility() != super.visibility())
|
if (function.visibility() != super.visibility())
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function visibility differs.");
|
||||||
function.location(),
|
|
||||||
"Overriding function visibility differs from " + super.fullyQualifiedName() + "."
|
|
||||||
);
|
|
||||||
|
|
||||||
if (function.isDeclaredConst() && !super.isDeclaredConst())
|
if (function.isDeclaredConst() && !super.isDeclaredConst())
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function should not be declared constant.");
|
||||||
function.location(),
|
|
||||||
"Overriding function should not be declared constant."
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!function.isDeclaredConst() && super.isDeclaredConst())
|
if (!function.isDeclaredConst() && super.isDeclaredConst())
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function should be declared constant.");
|
||||||
function.location(),
|
|
||||||
"Overriding function should be declared constant."
|
|
||||||
);
|
|
||||||
|
|
||||||
if (function.isPayable() && !super.isPayable())
|
if (function.isPayable() && !super.isPayable())
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function should not be declared payable.");
|
||||||
function.location(),
|
|
||||||
"Overriding function should not be declared payable."
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!function.isPayable() && super.isPayable())
|
if (!function.isPayable() && super.isPayable())
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function should be declared payable.");
|
||||||
function.location(),
|
|
||||||
"Overriding function should be declared payable."
|
|
||||||
);
|
|
||||||
|
|
||||||
if (functionType != superType)
|
if (functionType != superType)
|
||||||
m_errorReporter.typeError(
|
overrideError(function, super, "Overriding function return types differ.");
|
||||||
function.location(),
|
}
|
||||||
"Overriding function return types differ from " + super.fullyQualifiedName() + "."
|
|
||||||
);
|
void TypeChecker::overrideError(FunctionDefinition const& function, FunctionDefinition const& super, string message)
|
||||||
|
{
|
||||||
|
m_errorReporter.typeError(
|
||||||
|
function.location(),
|
||||||
|
SecondarySourceLocation().append("Overriden function is here:", super.location()),
|
||||||
|
message
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _contract)
|
void TypeChecker::checkContractExternalTypeClashes(ContractDefinition const& _contract)
|
||||||
|
@ -64,6 +64,7 @@ private:
|
|||||||
void checkContractIllegalOverrides(ContractDefinition const& _contract);
|
void checkContractIllegalOverrides(ContractDefinition const& _contract);
|
||||||
/// Reports a type error with an appropiate message if overriden function signature differs.
|
/// Reports a type error with an appropiate message if overriden function signature differs.
|
||||||
void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super);
|
void checkFunctionOverride(FunctionDefinition const& function, FunctionDefinition const& super);
|
||||||
|
void overrideError(FunctionDefinition const& function, FunctionDefinition const& super, std::string message);
|
||||||
void checkContractAbstractFunctions(ContractDefinition const& _contract);
|
void checkContractAbstractFunctions(ContractDefinition const& _contract);
|
||||||
void checkContractAbstractConstructors(ContractDefinition const& _contract);
|
void checkContractAbstractConstructors(ContractDefinition const& _contract);
|
||||||
/// Checks that different functions with external visibility end up having different
|
/// Checks that different functions with external visibility end up having different
|
||||||
|
@ -75,8 +75,8 @@ public:
|
|||||||
|
|
||||||
void typeError(
|
void typeError(
|
||||||
SourceLocation const& _location,
|
SourceLocation const& _location,
|
||||||
SecondarySourceLocation const& _secondaryLocation,
|
SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation(),
|
||||||
std::string const& _description
|
std::string const& _description = std::string()
|
||||||
);
|
);
|
||||||
|
|
||||||
void typeError(SourceLocation const& _location, std::string const& _description);
|
void typeError(SourceLocation const& _location, std::string const& _description);
|
||||||
|
Loading…
Reference in New Issue
Block a user