mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add error IDs to OverrideChecker
This commit is contained in:
parent
3fbde6e782
commit
1d5350e32f
@ -506,12 +506,13 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!_overriding.overrides())
|
if (!_overriding.overrides())
|
||||||
overrideError(_overriding, _super, "Overriding " + _overriding.astNodeName() + " is missing \"override\" specifier.");
|
overrideError(_overriding, _super, 9456_error, "Overriding " + _overriding.astNodeName() + " is missing \"override\" specifier.");
|
||||||
|
|
||||||
if (_super.isVariable())
|
if (_super.isVariable())
|
||||||
overrideError(
|
overrideError(
|
||||||
_super,
|
_super,
|
||||||
_overriding,
|
_overriding,
|
||||||
|
1452_error,
|
||||||
"Cannot override public state variable.",
|
"Cannot override public state variable.",
|
||||||
"Overriding " + _overriding.astNodeName() + " is here:"
|
"Overriding " + _overriding.astNodeName() + " is here:"
|
||||||
);
|
);
|
||||||
@ -519,6 +520,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
overrideError(
|
overrideError(
|
||||||
_super,
|
_super,
|
||||||
_overriding,
|
_overriding,
|
||||||
|
4334_error,
|
||||||
"Trying to override non-virtual " + _super.astNodeName() + ". Did you forget to add \"virtual\"?",
|
"Trying to override non-virtual " + _super.astNodeName() + ". Did you forget to add \"virtual\"?",
|
||||||
"Overriding " + _overriding.astNodeName() + " is here:"
|
"Overriding " + _overriding.astNodeName() + " is here:"
|
||||||
);
|
);
|
||||||
@ -526,7 +528,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
if (_overriding.isVariable())
|
if (_overriding.isVariable())
|
||||||
{
|
{
|
||||||
if (_super.visibility() != Visibility::External)
|
if (_super.visibility() != Visibility::External)
|
||||||
overrideError(_overriding, _super, "Public state variables can only override functions with external visibility.");
|
overrideError(_overriding, _super, 5225_error, "Public state variables can only override functions with external visibility.");
|
||||||
solAssert(_overriding.visibility() == Visibility::External, "");
|
solAssert(_overriding.visibility() == Visibility::External, "");
|
||||||
}
|
}
|
||||||
else if (_overriding.visibility() != _super.visibility())
|
else if (_overriding.visibility() != _super.visibility())
|
||||||
@ -537,7 +539,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
_super.visibility() == Visibility::External &&
|
_super.visibility() == Visibility::External &&
|
||||||
_overriding.visibility() == Visibility::Public
|
_overriding.visibility() == Visibility::Public
|
||||||
))
|
))
|
||||||
overrideError(_overriding, _super, "Overriding " + _overriding.astNodeName() + " visibility differs.");
|
overrideError(_overriding, _super, 9098_error, "Overriding " + _overriding.astNodeName() + " visibility differs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_super.isFunction())
|
if (_super.isFunction())
|
||||||
@ -548,7 +550,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
solAssert(functionType->hasEqualParameterTypes(*superType), "Override doesn't have equal parameters!");
|
solAssert(functionType->hasEqualParameterTypes(*superType), "Override doesn't have equal parameters!");
|
||||||
|
|
||||||
if (!functionType->hasEqualReturnTypes(*superType))
|
if (!functionType->hasEqualReturnTypes(*superType))
|
||||||
overrideError(_overriding, _super, "Overriding " + _overriding.astNodeName() + " return types differ.");
|
overrideError(_overriding, _super, 4822_error, "Overriding " + _overriding.astNodeName() + " return types differ.");
|
||||||
|
|
||||||
// This is only relevant for a function overriding a function.
|
// This is only relevant for a function overriding a function.
|
||||||
if (_overriding.isFunction())
|
if (_overriding.isFunction())
|
||||||
@ -557,6 +559,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
overrideError(
|
overrideError(
|
||||||
_overriding,
|
_overriding,
|
||||||
_super,
|
_super,
|
||||||
|
2837_error,
|
||||||
"Overriding function changes state mutability from \"" +
|
"Overriding function changes state mutability from \"" +
|
||||||
stateMutabilityToString(_super.stateMutability()) +
|
stateMutabilityToString(_super.stateMutability()) +
|
||||||
"\" to \"" +
|
"\" to \"" +
|
||||||
@ -568,6 +571,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
overrideError(
|
overrideError(
|
||||||
_overriding,
|
_overriding,
|
||||||
_super,
|
_super,
|
||||||
|
4593_error,
|
||||||
"Overriding an implemented function with an unimplemented function is not allowed."
|
"Overriding an implemented function with an unimplemented function is not allowed."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -577,6 +581,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
|
|||||||
void OverrideChecker::overrideListError(
|
void OverrideChecker::overrideListError(
|
||||||
OverrideProxy const& _item,
|
OverrideProxy const& _item,
|
||||||
set<ContractDefinition const*, CompareByID> _secondary,
|
set<ContractDefinition const*, CompareByID> _secondary,
|
||||||
|
ErrorId _error,
|
||||||
string const& _message1,
|
string const& _message1,
|
||||||
string const& _message2
|
string const& _message2
|
||||||
)
|
)
|
||||||
@ -594,7 +599,7 @@ void OverrideChecker::overrideListError(
|
|||||||
contractSingularPlural = "contracts ";
|
contractSingularPlural = "contracts ";
|
||||||
|
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
5883_error,
|
_error,
|
||||||
_item.overrides() ? _item.overrides()->location() : _item.location(),
|
_item.overrides() ? _item.overrides()->location() : _item.location(),
|
||||||
ssl,
|
ssl,
|
||||||
_message1 +
|
_message1 +
|
||||||
@ -605,10 +610,10 @@ void OverrideChecker::overrideListError(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverrideChecker::overrideError(Declaration const& _overriding, Declaration const& _super, string const& _message, string const& _secondaryMsg)
|
void OverrideChecker::overrideError(Declaration const& _overriding, Declaration const& _super, ErrorId _error, string const& _message, string const& _secondaryMsg)
|
||||||
{
|
{
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
9456_error,
|
_error,
|
||||||
_overriding.location(),
|
_overriding.location(),
|
||||||
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
|
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
|
||||||
_message
|
_message
|
||||||
@ -616,10 +621,10 @@ void OverrideChecker::overrideError(Declaration const& _overriding, Declaration
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OverrideChecker::overrideError(OverrideProxy const& _overriding, OverrideProxy const& _super, string const& _message, string const& _secondaryMsg)
|
void OverrideChecker::overrideError(OverrideProxy const& _overriding, OverrideProxy const& _super, ErrorId _error, string const& _message, string const& _secondaryMsg)
|
||||||
{
|
{
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
1452_error,
|
_error,
|
||||||
_overriding.location(),
|
_overriding.location(),
|
||||||
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
|
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
|
||||||
_message
|
_message
|
||||||
@ -773,11 +778,11 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign
|
|||||||
4520_error,
|
4520_error,
|
||||||
list[i]->location(),
|
list[i]->location(),
|
||||||
ssl,
|
ssl,
|
||||||
"Duplicate contract \"" +
|
"Duplicate contract \"" +
|
||||||
joinHumanReadable(list[i]->namePath(), ".") +
|
joinHumanReadable(list[i]->namePath(), ".") +
|
||||||
"\" found in override list of \"" +
|
"\" found in override list of \"" +
|
||||||
_item.name() +
|
_item.name() +
|
||||||
"\"."
|
"\"."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -810,6 +815,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign
|
|||||||
overrideListError(
|
overrideListError(
|
||||||
_item,
|
_item,
|
||||||
missingContracts,
|
missingContracts,
|
||||||
|
4327_error,
|
||||||
_item.astNodeNameCapitalized() + " needs to specify overridden ",
|
_item.astNodeNameCapitalized() + " needs to specify overridden ",
|
||||||
""
|
""
|
||||||
);
|
);
|
||||||
@ -819,6 +825,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign
|
|||||||
overrideListError(
|
overrideListError(
|
||||||
_item,
|
_item,
|
||||||
surplusContracts,
|
surplusContracts,
|
||||||
|
2353_error,
|
||||||
"Invalid ",
|
"Invalid ",
|
||||||
"specified in override list: "
|
"specified in override list: "
|
||||||
);
|
);
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
namespace solidity::langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
class ErrorReporter;
|
class ErrorReporter;
|
||||||
|
struct ErrorId;
|
||||||
struct SourceLocation;
|
struct SourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,18 +161,21 @@ private:
|
|||||||
void overrideListError(
|
void overrideListError(
|
||||||
OverrideProxy const& _item,
|
OverrideProxy const& _item,
|
||||||
std::set<ContractDefinition const*, CompareByID> _secondary,
|
std::set<ContractDefinition const*, CompareByID> _secondary,
|
||||||
|
langutil::ErrorId _error,
|
||||||
std::string const& _message1,
|
std::string const& _message1,
|
||||||
std::string const& _message2
|
std::string const& _message2
|
||||||
);
|
);
|
||||||
void overrideError(
|
void overrideError(
|
||||||
Declaration const& _overriding,
|
Declaration const& _overriding,
|
||||||
Declaration const& _super,
|
Declaration const& _super,
|
||||||
|
langutil::ErrorId _error,
|
||||||
std::string const& _message,
|
std::string const& _message,
|
||||||
std::string const& _secondaryMsg = "Overridden function is here:"
|
std::string const& _secondaryMsg = "Overridden function is here:"
|
||||||
);
|
);
|
||||||
void overrideError(
|
void overrideError(
|
||||||
OverrideProxy const& _overriding,
|
OverrideProxy const& _overriding,
|
||||||
OverrideProxy const& _super,
|
OverrideProxy const& _super,
|
||||||
|
langutil::ErrorId _error,
|
||||||
std::string const& _message,
|
std::string const& _message,
|
||||||
std::string const& _secondaryMsg = "Overridden function is here:"
|
std::string const& _secondaryMsg = "Overridden function is here:"
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user