Add unique IDs to error reporting calls

This commit is contained in:
a3d4 2020-05-06 00:38:28 +02:00
parent e3641b88ec
commit 8f68c04358
24 changed files with 382 additions and 193 deletions

View File

@ -145,12 +145,12 @@ void ParserBase::decreaseRecursionDepth()
void ParserBase::parserWarning(string const& _description)
{
m_errorReporter.warning(currentLocation(), _description);
m_errorReporter.warning(6635_error, currentLocation(), _description);
}
void ParserBase::parserError(SourceLocation const& _location, string const& _description)
{
m_errorReporter.parserError(_location, _description);
m_errorReporter.parserError(2314_error, _location, _description);
}
void ParserBase::parserError(string const& _description)
@ -165,5 +165,5 @@ void ParserBase::fatalParserError(string const& _description)
void ParserBase::fatalParserError(SourceLocation const& _location, string const& _description)
{
m_errorReporter.fatalParserError(_location, _description);
m_errorReporter.fatalParserError(1957_error, _location, _description);
}

View File

@ -47,6 +47,7 @@ void ConstantEvaluator::endVisit(BinaryOperation const& _operation)
TypePointer commonType = left->binaryOperatorResult(_operation.getOperator(), right);
if (!commonType)
m_errorReporter.fatalTypeError(
6020_error,
_operation.location(),
"Operator " +
string(TokenTraits::toString(_operation.getOperator())) +
@ -83,7 +84,7 @@ void ConstantEvaluator::endVisit(Identifier const& _identifier)
else if (!m_types->count(value.get()))
{
if (m_depth > 32)
m_errorReporter.fatalTypeError(_identifier.location(), "Cyclic constant definition (or maximum recursion depth exhausted).");
m_errorReporter.fatalTypeError(5210_error, _identifier.location(), "Cyclic constant definition (or maximum recursion depth exhausted).");
ConstantEvaluator(m_errorReporter, m_depth + 1, m_types).evaluate(*value);
}

View File

@ -78,6 +78,7 @@ void ContractLevelChecker::checkDuplicateFunctions(ContractDefinition const& _co
{
if (constructor)
m_errorReporter.declarationError(
7997_error,
function->location(),
SecondarySourceLocation().append("Another declaration is here:", constructor->location()),
"More than one constructor defined."
@ -88,6 +89,7 @@ void ContractLevelChecker::checkDuplicateFunctions(ContractDefinition const& _co
{
if (fallback)
m_errorReporter.declarationError(
7301_error,
function->location(),
SecondarySourceLocation().append("Another declaration is here:", fallback->location()),
"Only one fallback function is allowed."
@ -98,6 +100,7 @@ void ContractLevelChecker::checkDuplicateFunctions(ContractDefinition const& _co
{
if (receive)
m_errorReporter.declarationError(
4046_error,
function->location(),
SecondarySourceLocation().append("Another declaration is here:", receive->location()),
"Only one receive function is allowed."
@ -147,6 +150,7 @@ void ContractLevelChecker::findDuplicateDefinitions(map<string, vector<T>> const
ssl.limitSize(_message);
m_errorReporter.declarationError(
1686_error,
overloads[i]->location(),
ssl,
_message
@ -197,9 +201,9 @@ void ContractLevelChecker::checkAbstractDefinitions(ContractDefinition const& _c
if (_contract.abstract())
{
if (_contract.contractKind() == ContractKind::Interface)
m_errorReporter.typeError(_contract.location(), "Interfaces do not need the \"abstract\" keyword, they are abstract implicitly.");
m_errorReporter.typeError(9348_error, _contract.location(), "Interfaces do not need the \"abstract\" keyword, they are abstract implicitly.");
else if (_contract.contractKind() == ContractKind::Library)
m_errorReporter.typeError(_contract.location(), "Libraries cannot be abstract.");
m_errorReporter.typeError(9571_error, _contract.location(), "Libraries cannot be abstract.");
else
solAssert(_contract.contractKind() == ContractKind::Contract, "");
}
@ -215,7 +219,8 @@ void ContractLevelChecker::checkAbstractDefinitions(ContractDefinition const& _c
SecondarySourceLocation ssl;
for (auto declaration: _contract.annotation().unimplementedDeclarations)
ssl.append("Missing implementation: ", declaration->location());
m_errorReporter.typeError(_contract.location(), ssl,
m_errorReporter.typeError(
3656_error,_contract.location(), ssl,
"Contract \"" + _contract.annotation().canonicalName
+ "\" should be marked as abstract.");
@ -243,6 +248,7 @@ void ContractLevelChecker::checkBaseConstructorArguments(ContractDefinition cons
}
else
m_errorReporter.declarationError(
1563_error,
modifier->location(),
"Modifier-style base constructor call without arguments."
);
@ -304,6 +310,7 @@ void ContractLevelChecker::annotateBaseConstructorArguments(
}
m_errorReporter.declarationError(
3364_error,
*mainLocation,
ssl,
"Base constructor arguments given twice."
@ -343,6 +350,7 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
for (size_t j = i + 1; j < it.second.size(); ++j)
if (!it.second[i].second->hasEqualParameterTypes(*it.second[j].second))
m_errorReporter.typeError(
9914_error,
it.second[j].first->location(),
"Function overload clash during conversion to external types for arguments."
);
@ -356,6 +364,7 @@ void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contra
util::FixedHash<4> const& hash = it.first;
if (hashes.count(hash))
m_errorReporter.typeError(
1860_error,
_contract.location(),
string("Function signature hash collision for ") + it.second->externalSignature()
);
@ -369,11 +378,11 @@ void ContractLevelChecker::checkLibraryRequirements(ContractDefinition const& _c
return;
if (!_contract.baseContracts().empty())
m_errorReporter.typeError(_contract.location(), "Library is not allowed to inherit.");
m_errorReporter.typeError(9469_error, _contract.location(), "Library is not allowed to inherit.");
for (auto const& var: _contract.stateVariables())
if (!var->isConstant())
m_errorReporter.typeError(var->location(), "Library cannot have non-constant state variables");
m_errorReporter.typeError(9957_error, var->location(), "Library cannot have non-constant state variables");
}
void ContractLevelChecker::checkBaseABICompatibility(ContractDefinition const& _contract)
@ -412,6 +421,7 @@ void ContractLevelChecker::checkBaseABICompatibility(ContractDefinition const& _
if (!errors.infos.empty())
m_errorReporter.fatalTypeError(
6594_error,
_contract.location(),
errors,
std::string("Contract \"") +
@ -428,6 +438,7 @@ void ContractLevelChecker::checkPayableFallbackWithoutReceive(ContractDefinition
if (auto const* fallback = _contract.fallbackFunction())
if (fallback->isPayable() && !_contract.interfaceFunctionList().empty() && !_contract.receiveFunction())
m_errorReporter.warning(
3628_error,
_contract.location(),
"This contract has a payable fallback function, but no receive ether function. Consider adding a receive ether function.",
SecondarySourceLocation{}.append("The payable fallback function is defined here.", fallback->location())

View File

@ -136,6 +136,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod
ssl.append("The variable was declared here.", variableOccurrence->declaration().location());
m_errorReporter.typeError(
3464_error,
variableOccurrence->occurrence() ?
*variableOccurrence->occurrence() :
variableOccurrence->declaration().location(),
@ -176,6 +177,6 @@ void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const*
// Extend the location, as long as the next location overlaps (unreachable is sorted).
for (; it != unreachable.end() && it->start <= location.end; ++it)
location.end = std::max(location.end, it->end);
m_errorReporter.warning(location, "Unreachable code.");
m_errorReporter.warning(5740_error, location, "Unreachable code.");
}
}

View File

@ -188,12 +188,14 @@ void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
{
if (contractType->contractDefinition().isLibrary())
m_errorReporter.fatalTypeError(
1665_error,
typeName->location(),
"Library types cannot be used as mapping keys."
);
}
else if (typeName->annotation().type->category() != Type::Category::Enum)
m_errorReporter.fatalTypeError(
7804_error,
typeName->location(),
"Only elementary types, contract types or enums are allowed as mapping keys."
);
@ -253,9 +255,9 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
return;
if (_variable.isConstant() && !_variable.isStateVariable())
m_errorReporter.declarationError(_variable.location(), "The \"constant\" keyword can only be used for state variables.");
m_errorReporter.declarationError(1788_error, _variable.location(), "The \"constant\" keyword can only be used for state variables.");
if (_variable.immutable() && !_variable.isStateVariable())
m_errorReporter.declarationError(_variable.location(), "The \"immutable\" keyword can only be used for state variables.");
m_errorReporter.declarationError(8297_error, _variable.location(), "The \"immutable\" keyword can only be used for state variables.");
if (!_variable.typeName())
{
@ -360,19 +362,19 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
void DeclarationTypeChecker::typeError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.typeError(_location, _description);
m_errorReporter.typeError(2311_error, _location, _description);
}
void DeclarationTypeChecker::fatalTypeError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.fatalTypeError(_location, _description);
m_errorReporter.fatalTypeError(5651_error, _location, _description);
}
void DeclarationTypeChecker::fatalDeclarationError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(_location, _description);
m_errorReporter.fatalDeclarationError(2046_error, _location, _description);
}
bool DeclarationTypeChecker::check(ASTNode const& _node)

View File

@ -173,5 +173,5 @@ void DocStringAnalyser::parseDocStrings(
void DocStringAnalyser::appendError(SourceLocation const& _location, string const& _description)
{
m_errorOccured = true;
m_errorReporter.docstringParsingError(_location, _description);
m_errorReporter.docstringParsingError(7816_error, _location, _description);
}

View File

@ -166,33 +166,39 @@ void ImmutableValidator::analyseVariableReference(VariableDeclaration const& _va
{
if (!m_currentConstructor)
m_errorReporter.typeError(
1581_error,
_expression.location(),
"Immutable variables can only be initialized inline or assigned directly in the constructor."
);
else if (m_currentConstructor->annotation().contract->id() != _variableReference.annotation().contract->id())
m_errorReporter.typeError(
7484_error,
_expression.location(),
"Immutable variables must be initialized in the constructor of the contract they are defined in."
);
else if (m_inLoop)
m_errorReporter.typeError(
6672_error,
_expression.location(),
"Immutable variables can only be initialized once, not in a while statement."
);
else if (m_inBranch)
m_errorReporter.typeError(
4599_error,
_expression.location(),
"Immutable variables must be initialized unconditionally, not in an if statement."
);
if (!m_initializedStateVariables.emplace(&_variableReference).second)
m_errorReporter.typeError(
1574_error,
_expression.location(),
"Immutable state variable already initialized."
);
}
else if (m_inConstructionContext)
m_errorReporter.typeError(
7733_error,
_expression.location(),
"Immutable variables cannot be read during contract creation time, which means "
"they cannot be read in the constructor or any function or modifier called from it."
@ -206,6 +212,7 @@ void ImmutableValidator::checkAllVariablesInitialized(solidity::langutil::Source
if (varDecl->immutable())
if (!util::contains(m_initializedStateVariables, varDecl))
m_errorReporter.typeError(
2658_error,
_location,
solidity::langutil::SecondarySourceLocation().append("Not initialized: ", varDecl->location()),
"Construction control flow ends without initializing all immutable state variables."

View File

@ -80,6 +80,7 @@ bool NameAndTypeResolver::performImports(SourceUnit& _sourceUnit, map<string, So
if (!_sourceUnits.count(path))
{
m_errorReporter.declarationError(
5073_error,
imp->location(),
"Import \"" + path + "\" (referenced as \"" + imp->path() + "\") not found."
);
@ -95,6 +96,7 @@ bool NameAndTypeResolver::performImports(SourceUnit& _sourceUnit, map<string, So
if (declarations.empty())
{
m_errorReporter.declarationError(
2904_error,
imp->location(),
"Declaration \"" +
alias.symbol->name() +
@ -208,6 +210,7 @@ void NameAndTypeResolver::warnVariablesNamedLikeInstructions()
// Don't warn the user for what the user did not.
continue;
m_errorReporter.warning(
8261_error,
declaration->location(),
"Variable is shadowed in inline assembly by an instruction of the same name"
);
@ -326,6 +329,7 @@ void NameAndTypeResolver::importInheritedScope(ContractDefinition const& _base)
}
m_errorReporter.declarationError(
9097_error,
secondDeclarationLocation,
SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation),
"Identifier already declared."
@ -343,19 +347,19 @@ void NameAndTypeResolver::linearizeBaseContracts(ContractDefinition& _contract)
UserDefinedTypeName const& baseName = baseSpecifier->name();
auto base = dynamic_cast<ContractDefinition const*>(baseName.annotation().referencedDeclaration);
if (!base)
m_errorReporter.fatalTypeError(baseName.location(), "Contract expected.");
m_errorReporter.fatalTypeError(8758_error, baseName.location(), "Contract expected.");
// "push_front" has the effect that bases mentioned later can overwrite members of bases
// mentioned earlier
input.back().push_front(base);
vector<ContractDefinition const*> const& basesBases = base->annotation().linearizedBaseContracts;
if (basesBases.empty())
m_errorReporter.fatalTypeError(baseName.location(), "Definition of base has to precede definition of derived contract");
m_errorReporter.fatalTypeError(2449_error, baseName.location(), "Definition of base has to precede definition of derived contract");
input.push_front(list<ContractDefinition const*>(basesBases.begin(), basesBases.end()));
}
input.back().push_front(&_contract);
vector<ContractDefinition const*> result = cThreeMerge(input);
if (result.empty())
m_errorReporter.fatalTypeError(_contract.location(), "Linearization of inheritance graph impossible");
m_errorReporter.fatalTypeError(5005_error, _contract.location(), "Linearization of inheritance graph impossible");
_contract.annotation().linearizedBaseContracts = result;
_contract.annotation().contractDependencies.insert(result.begin() + 1, result.end());
}
@ -476,6 +480,7 @@ bool DeclarationRegistrationHelper::registerDeclaration(
}
_errorReporter.declarationError(
2333_error,
secondDeclarationLocation,
SecondarySourceLocation().append("The previous declaration is here:", firstDeclarationLocation),
"Identifier already declared."
@ -486,6 +491,7 @@ bool DeclarationRegistrationHelper::registerDeclaration(
{
if (dynamic_cast<MagicVariableDeclaration const*>(shadowedDeclaration))
_errorReporter.warning(
2319_error,
*_errorLocation,
"This declaration shadows a builtin symbol."
);
@ -493,6 +499,7 @@ bool DeclarationRegistrationHelper::registerDeclaration(
{
auto shadowedLocation = shadowedDeclaration->location();
_errorReporter.warning(
2519_error,
_declaration.location(),
"This declaration shadows an existing declaration.",
SecondarySourceLocation().append("The shadowed declaration is here:", shadowedLocation)

View File

@ -461,6 +461,7 @@ void OverrideChecker::checkIllegalOverrides(ContractDefinition const& _contract)
{
if (contains_if(inheritedFuncs, MatchByName{modifier->name()}))
m_errorReporter.typeError(
5631_error,
modifier->location(),
"Override changes function or public state variable to modifier."
);
@ -474,7 +475,7 @@ void OverrideChecker::checkIllegalOverrides(ContractDefinition const& _contract)
continue;
if (contains_if(inheritedMods, MatchByName{function->name()}))
m_errorReporter.typeError(function->location(), "Override changes modifier to function.");
m_errorReporter.typeError(1469_error, function->location(), "Override changes modifier to function.");
checkOverrideList(OverrideProxy{function}, inheritedFuncs);
}
@ -484,7 +485,7 @@ void OverrideChecker::checkIllegalOverrides(ContractDefinition const& _contract)
continue;
if (contains_if(inheritedMods, MatchByName{stateVar->name()}))
m_errorReporter.typeError(stateVar->location(), "Override changes modifier to public state variable.");
m_errorReporter.typeError(1456_error, stateVar->location(), "Override changes modifier to public state variable.");
checkOverrideList(OverrideProxy{stateVar}, inheritedFuncs);
}
@ -500,6 +501,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
if (_overriding.isModifier() && *_overriding.modifierType() != *_super.modifierType())
m_errorReporter.typeError(
1078_error,
_overriding.location(),
"Override changes modifier signature."
);
@ -593,6 +595,7 @@ void OverrideChecker::overrideListError(
contractSingularPlural = "contracts ";
m_errorReporter.typeError(
5883_error,
_item.overrides() ? _item.overrides()->location() : _item.location(),
ssl,
_message1 +
@ -606,6 +609,7 @@ void OverrideChecker::overrideListError(
void OverrideChecker::overrideError(Declaration const& _overriding, Declaration const& _super, string const& _message, string const& _secondaryMsg)
{
m_errorReporter.typeError(
9456_error,
_overriding.location(),
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
_message
@ -616,6 +620,7 @@ void OverrideChecker::overrideError(Declaration const& _overriding, Declaration
void OverrideChecker::overrideError(OverrideProxy const& _overriding, OverrideProxy const& _super, string const& _message, string const& _secondaryMsg)
{
m_errorReporter.typeError(
1452_error,
_overriding.location(),
SecondarySourceLocation().append(_secondaryMsg, _super.location()),
_message
@ -718,7 +723,7 @@ void OverrideChecker::checkAmbiguousOverridesInternal(set<OverrideProxy> _baseCa
" Since one of the bases defines a public state variable which cannot be overridden, "
"you have to change the inheritance layout or the names of the functions.";
m_errorReporter.typeError(_location, ssl, message);
m_errorReporter.typeError(6480_error, _location, ssl, message);
}
set<ContractDefinition const*, OverrideChecker::CompareByID> OverrideChecker::resolveOverrideList(OverrideSpecifier const& _overrides) const
@ -766,6 +771,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign
SecondarySourceLocation ssl;
ssl.append("First occurrence here: ", list[i-1]->location());
m_errorReporter.typeError(
4520_error,
list[i]->location(),
ssl,
"Duplicate contract \"" +
@ -791,6 +797,7 @@ void OverrideChecker::checkOverrideList(OverrideProxy _item, OverrideProxyBySign
if (_item.overrides() && expectedContracts.empty())
m_errorReporter.typeError(
7792_error,
_item.overrides()->location(),
_item.astNodeNameCapitalized() + " has override specified but does not override anything."
);

View File

@ -122,6 +122,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
for (auto declaration: m_constVariables)
if (auto identifier = findCycle(*declaration))
m_errorReporter.typeError(
6161_error,
declaration->location(),
"The value of the constant " + declaration->name() +
" has a cyclic dependency via " + identifier->name() + "."
@ -165,7 +166,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
auto visitor = [&](VariableDeclaration const& _variable, util::CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth)
{
if (_depth >= 256)
m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator.");
m_errorReporter.fatalDeclarationError(7380_error, _variable.location(), "Variable definition exhausting cyclic dependency validator.");
// Iterating through the dependencies needs to be deterministic and thus cannot
// depend on the memory layout.
@ -209,6 +210,7 @@ struct OverrideSpecifierChecker: public PostTypeChecker::Checker
TypeType const* actualTypeType = dynamic_cast<TypeType const*>(decl->type());
m_errorReporter.typeError(
9301_error,
override->location(),
"Expected contract but got " +
actualTypeType->actualType()->toString(true) +
@ -243,6 +245,7 @@ struct ModifierContextChecker: public PostTypeChecker::Checker
if (ModifierType const* type = dynamic_cast<decltype(type)>(_identifier.annotation().type))
{
m_errorReporter.typeError(
3112_error,
_identifier.location(),
"Modifier can only be referenced in function headers."
);
@ -280,6 +283,7 @@ struct EventOutsideEmitChecker: public PostTypeChecker::Checker
// Check for event outside of emit statement
if (!m_insideEmitStatement && functionType->kind() == FunctionType::Kind::Event)
m_errorReporter.typeError(
3132_error,
_functionCall.location(),
"Event invocations have to be prefixed by \"emit\"."
);
@ -308,7 +312,7 @@ struct NoVariablesInInterfaceChecker: public PostTypeChecker::Checker
&& !_variable.isCallableOrCatchParameter()
&& !m_insideStruct
)
m_errorReporter.typeError(_variable.location(), "Variables cannot be declared in interfaces.");
m_errorReporter.typeError(8274_error, _variable.location(), "Variables cannot be declared in interfaces.");
return true;
}

View File

@ -268,19 +268,19 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
void ReferencesResolver::declarationError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.declarationError(_location, _description);
m_errorReporter.declarationError(8532_error, _location, _description);
}
void ReferencesResolver::declarationError(SourceLocation const& _location, SecondarySourceLocation const& _ssl, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.declarationError(_location, _ssl, _description);
m_errorReporter.declarationError(3881_error, _location, _ssl, _description);
}
void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location, string const& _description)
{
m_errorOccurred = true;
m_errorReporter.fatalDeclarationError(_location, _description);
m_errorReporter.fatalDeclarationError(6546_error, _location, _description);
}
}

View File

@ -120,13 +120,14 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&)
{
if (var.first.second->isCallableOrCatchParameter())
m_errorReporter.warning(
5667_error,
var.first.second->location(),
"Unused " +
string(var.first.second->isTryCatchParameter() ? "try/catch" : "function") +
" parameter. Remove or comment out the variable name to silence this warning."
);
else
m_errorReporter.warning(var.first.second->location(), "Unused local variable.");
m_errorReporter.warning(2072_error, var.first.second->location(), "Unused local variable.");
}
m_localVarUseCount.clear();
m_constructor = false;
@ -159,6 +160,7 @@ bool StaticAnalyzer::visit(VariableDeclaration const& _variable)
set<StructDefinition const*> structsSeen;
if (structureSizeEstimate(*_variable.type(), structsSeen) >= bigint(1) << 64)
m_errorReporter.warning(
3408_error,
_variable.location(),
"Variable covers a large part of storage and thus makes collisions likely. "
"Either use mappings or dynamic arrays and allow their size to be increased only "
@ -183,6 +185,7 @@ bool StaticAnalyzer::visit(ExpressionStatement const& _statement)
{
if (_statement.expression().annotation().isPure)
m_errorReporter.warning(
6133_error,
_statement.location(),
"Statement has no effect."
);
@ -196,11 +199,13 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
{
if (type->kind() == MagicType::Kind::Message && _memberAccess.memberName() == "gas")
m_errorReporter.typeError(
1400_error,
_memberAccess.location(),
"\"msg.gas\" has been deprecated in favor of \"gasleft()\""
);
else if (type->kind() == MagicType::Kind::Block && _memberAccess.memberName() == "blockhash")
m_errorReporter.typeError(
8113_error,
_memberAccess.location(),
"\"block.blockhash()\" has been deprecated in favor of \"blockhash()\""
);
@ -211,6 +216,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
ContractType const& contract = dynamic_cast<ContractType const&>(*type->typeArgument());
if (m_constructorUsesAssembly->check(contract.contractDefinition()))
m_errorReporter.warning(
6417_error,
_memberAccess.location(),
"The constructor of the contract (or its base) uses inline assembly. "
"Because of that, it might be that the deployed bytecode is different from type(...).runtimeCode."
@ -222,6 +228,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type))
if (type->kind() == FunctionType::Kind::BareCallCode)
m_errorReporter.typeError(
2256_error,
_memberAccess.location(),
"\"callcode\" has been deprecated in favour of \"delegatecall\"."
);
@ -235,6 +242,7 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess)
{
if (id->name() == "this")
m_errorReporter.warning(
5805_error,
id->location(),
"\"this\" used in constructor. "
"Note that external functions of a contract "
@ -285,6 +293,7 @@ bool StaticAnalyzer::visit(BinaryOperation const& _operation)
))
if (rhs->isZero())
m_errorReporter.typeError(
1211_error,
_operation.location(),
(_operation.getOperator() == Token::Div) ? "Division by zero." : "Modulo zero."
);
@ -307,6 +316,7 @@ bool StaticAnalyzer::visit(FunctionCall const& _functionCall)
))
if (lastArg->isZero())
m_errorReporter.typeError(
4195_error,
_functionCall.location(),
"Arithmetic modulo zero."
);
@ -317,6 +327,7 @@ bool StaticAnalyzer::visit(FunctionCall const& _functionCall)
functionType->declaration().scope() == m_currentContract
)
m_errorReporter.typeError(
6700_error,
_functionCall.location(),
SecondarySourceLocation().append(
"The function declaration is here:",

View File

@ -69,7 +69,7 @@ void SyntaxChecker::endVisit(SourceUnit const& _sourceUnit)
string(";\"");
// when reporting the warning, print the source name only
m_errorReporter.warning({-1, -1, _sourceUnit.location().source}, errorString);
m_errorReporter.warning(3420_error, {-1, -1, _sourceUnit.location().source}, errorString);
}
m_sourceUnit = nullptr;
}
@ -79,18 +79,20 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
solAssert(!_pragma.tokens().empty(), "");
solAssert(_pragma.tokens().size() == _pragma.literals().size(), "");
if (_pragma.tokens()[0] != Token::Identifier)
m_errorReporter.syntaxError(_pragma.location(), "Invalid pragma \"" + _pragma.literals()[0] + "\"");
m_errorReporter.syntaxError(5226_error, _pragma.location(), "Invalid pragma \"" + _pragma.literals()[0] + "\"");
else if (_pragma.literals()[0] == "experimental")
{
solAssert(m_sourceUnit, "");
vector<string> literals(_pragma.literals().begin() + 1, _pragma.literals().end());
if (literals.empty())
m_errorReporter.syntaxError(
9679_error,
_pragma.location(),
"Experimental feature name is missing."
);
else if (literals.size() > 1)
m_errorReporter.syntaxError(
6022_error,
_pragma.location(),
"Stray arguments."
);
@ -98,17 +100,17 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
{
string const literal = literals[0];
if (literal.empty())
m_errorReporter.syntaxError(_pragma.location(), "Empty experimental feature name is invalid.");
m_errorReporter.syntaxError(3250_error, _pragma.location(), "Empty experimental feature name is invalid.");
else if (!ExperimentalFeatureNames.count(literal))
m_errorReporter.syntaxError(_pragma.location(), "Unsupported experimental feature name.");
m_errorReporter.syntaxError(8491_error, _pragma.location(), "Unsupported experimental feature name.");
else if (m_sourceUnit->annotation().experimentalFeatures.count(ExperimentalFeatureNames.at(literal)))
m_errorReporter.syntaxError(_pragma.location(), "Duplicate experimental feature name.");
m_errorReporter.syntaxError(1231_error, _pragma.location(), "Duplicate experimental feature name.");
else
{
auto feature = ExperimentalFeatureNames.at(literal);
m_sourceUnit->annotation().experimentalFeatures.insert(feature);
if (!ExperimentalFeatureWithoutWarning.count(feature))
m_errorReporter.warning(_pragma.location(), "Experimental features are turned on. Do not use experimental features on live deployments.");
m_errorReporter.warning(2264_error, _pragma.location(), "Experimental features are turned on. Do not use experimental features on live deployments.");
}
}
}
@ -121,6 +123,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
static SemVerVersion const currentVersion{string(VersionString)};
if (!matchExpression.matches(currentVersion))
m_errorReporter.syntaxError(
3997_error,
_pragma.location(),
"Source file requires different compiler version (current compiler is " +
string(VersionString) + ") - note that nightly builds are considered to be "
@ -129,7 +132,7 @@ bool SyntaxChecker::visit(PragmaDirective const& _pragma)
m_versionPragmaFound = true;
}
else
m_errorReporter.syntaxError(_pragma.location(), "Unknown pragma \"" + _pragma.literals()[0] + "\"");
m_errorReporter.syntaxError(4936_error, _pragma.location(), "Unknown pragma \"" + _pragma.literals()[0] + "\"");
return true;
}
@ -142,7 +145,7 @@ bool SyntaxChecker::visit(ModifierDefinition const&)
void SyntaxChecker::endVisit(ModifierDefinition const& _modifier)
{
if (_modifier.isImplemented() && !m_placeholderFound)
m_errorReporter.syntaxError(_modifier.body().location(), "Modifier body does not contain '_'.");
m_errorReporter.syntaxError(2883_error, _modifier.body().location(), "Modifier body does not contain '_'.");
m_placeholderFound = false;
}
@ -150,7 +153,7 @@ void SyntaxChecker::checkSingleStatementVariableDeclaration(ASTNode const& _stat
{
auto varDecl = dynamic_cast<VariableDeclarationStatement const*>(&_statement);
if (varDecl)
m_errorReporter.syntaxError(_statement.location(), "Variable declarations can only be used inside blocks.");
m_errorReporter.syntaxError(9079_error, _statement.location(), "Variable declarations can only be used inside blocks.");
}
bool SyntaxChecker::visit(IfStatement const& _ifStatement)
@ -189,7 +192,7 @@ bool SyntaxChecker::visit(Continue const& _continueStatement)
{
if (m_inLoopDepth <= 0)
// we're not in a for/while loop, report syntax error
m_errorReporter.syntaxError(_continueStatement.location(), "\"continue\" has to be in a \"for\" or \"while\" loop.");
m_errorReporter.syntaxError(4123_error, _continueStatement.location(), "\"continue\" has to be in a \"for\" or \"while\" loop.");
return true;
}
@ -197,13 +200,14 @@ bool SyntaxChecker::visit(Break const& _breakStatement)
{
if (m_inLoopDepth <= 0)
// we're not in a for/while loop, report syntax error
m_errorReporter.syntaxError(_breakStatement.location(), "\"break\" has to be in a \"for\" or \"while\" loop.");
m_errorReporter.syntaxError(6102_error, _breakStatement.location(), "\"break\" has to be in a \"for\" or \"while\" loop.");
return true;
}
bool SyntaxChecker::visit(Throw const& _throwStatement)
{
m_errorReporter.syntaxError(
4538_error,
_throwStatement.location(),
"\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"."
);
@ -222,29 +226,29 @@ bool SyntaxChecker::visit(Literal const& _literal)
// Generic checks no matter what base this number literal is of:
if (value.back() == '_')
{
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. No trailing underscores allowed.");
m_errorReporter.syntaxError(2090_error, _literal.location(), "Invalid use of underscores in number literal. No trailing underscores allowed.");
return true;
}
if (value.find("__") != ASTString::npos)
{
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed.");
m_errorReporter.syntaxError(2990_error, _literal.location(), "Invalid use of underscores in number literal. Only one consecutive underscores between digits allowed.");
return true;
}
if (!_literal.isHexNumber()) // decimal literal
{
if (value.find("._") != ASTString::npos)
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.");
m_errorReporter.syntaxError(3891_error, _literal.location(), "Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.");
if (value.find("_.") != ASTString::npos)
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.");
m_errorReporter.syntaxError(1023_error, _literal.location(), "Invalid use of underscores in number literal. No underscores in front of the fraction part allowed.");
if (value.find("_e") != ASTString::npos)
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. No underscore at the end of the mantissa allowed.");
m_errorReporter.syntaxError(6415_error, _literal.location(), "Invalid use of underscores in number literal. No underscore at the end of the mantissa allowed.");
if (value.find("e_") != ASTString::npos)
m_errorReporter.syntaxError(_literal.location(), "Invalid use of underscores in number literal. No underscore in front of exponent allowed.");
m_errorReporter.syntaxError(6165_error, _literal.location(), "Invalid use of underscores in number literal. No underscore in front of exponent allowed.");
}
return true;
@ -253,7 +257,7 @@ bool SyntaxChecker::visit(Literal const& _literal)
bool SyntaxChecker::visit(UnaryOperation const& _operation)
{
if (_operation.getOperator() == Token::Add)
m_errorReporter.syntaxError(_operation.location(), "Use of unary + is disallowed.");
m_errorReporter.syntaxError(9636_error, _operation.location(), "Use of unary + is disallowed.");
return true;
}
@ -265,6 +269,7 @@ bool SyntaxChecker::visit(InlineAssembly const& _inlineAssembly)
if (yul::MSizeFinder::containsMSize(_inlineAssembly.dialect(), _inlineAssembly.operations()))
m_errorReporter.syntaxError(
6553_error,
_inlineAssembly.location(),
"The msize instruction cannot be used when the Yul optimizer is activated because "
"it can change its semantics. Either disable the Yul optimizer or do not use the instruction."
@ -285,7 +290,8 @@ bool SyntaxChecker::visit(ContractDefinition const& _contract)
ASTString const& contractName = _contract.name();
for (FunctionDefinition const* function: _contract.definedFunctions())
if (function->name() == contractName)
m_errorReporter.syntaxError(function->location(),
m_errorReporter.syntaxError(
5796_error,function->location(),
"Functions are not allowed to have the same name as the contract. "
"If you intend this to be a constructor, use \"constructor(...) { ... }\" to define it."
);
@ -298,15 +304,16 @@ bool SyntaxChecker::visit(FunctionDefinition const& _function)
{
string suggestedVisibility = _function.isFallback() || _function.isReceive() || m_isInterface ? "external" : "public";
m_errorReporter.syntaxError(
4937_error,
_function.location(),
"No visibility specified. Did you intend to add \"" + suggestedVisibility + "\"?"
);
}
if (m_isInterface && !_function.modifiers().empty())
m_errorReporter.syntaxError(_function.location(), "Functions in interfaces cannot have modifiers.");
m_errorReporter.syntaxError(5842_error, _function.location(), "Functions in interfaces cannot have modifiers.");
else if (!_function.isImplemented() && !_function.modifiers().empty())
m_errorReporter.syntaxError(_function.location(), "Functions without implementation cannot have modifiers.");
m_errorReporter.syntaxError(2668_error, _function.location(), "Functions without implementation cannot have modifiers.");
return true;
}
@ -315,11 +322,11 @@ bool SyntaxChecker::visit(FunctionTypeName const& _node)
{
for (auto const& decl: _node.parameterTypeList()->parameters())
if (!decl->name().empty())
m_errorReporter.warning(decl->location(), "Naming function type parameters is deprecated.");
m_errorReporter.warning(6162_error, decl->location(), "Naming function type parameters is deprecated.");
for (auto const& decl: _node.returnParameterTypeList()->parameters())
if (!decl->name().empty())
m_errorReporter.syntaxError(decl->location(), "Return parameters in function types may not be named.");
m_errorReporter.syntaxError(7304_error, decl->location(), "Return parameters in function types may not be named.");
return true;
}
@ -329,6 +336,7 @@ bool SyntaxChecker::visit(VariableDeclarationStatement const& _statement)
// Report if none of the variable components in the tuple have a name (only possible via deprecated "var")
if (boost::algorithm::all_of_equal(_statement.declarations(), nullptr))
m_errorReporter.syntaxError(
3299_error,
_statement.location(),
"The use of the \"var\" keyword is disallowed. The declaration part of the statement can be removed, since it is empty."
);
@ -339,7 +347,7 @@ bool SyntaxChecker::visit(VariableDeclarationStatement const& _statement)
bool SyntaxChecker::visit(StructDefinition const& _struct)
{
if (_struct.members().empty())
m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
m_errorReporter.syntaxError(5306_error, _struct.location(), "Defining empty structs is disallowed.");
return true;
}

File diff suppressed because it is too large Load Diff

View File

@ -171,6 +171,7 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef)
!_funDef.overrides()
)
m_errorReporter.warning(
2018_error,
_funDef.location(),
"Function state mutability can be restricted to " + stateMutabilityToString(m_bestMutabilityAndLocation.mutability)
);
@ -252,6 +253,7 @@ void ViewPureChecker::reportMutability(
))
{
m_errorReporter.typeError(
2527_error,
_location,
"Function declared as pure, but this expression (potentially) reads from the "
"environment or state and thus requires \"view\"."
@ -261,6 +263,7 @@ void ViewPureChecker::reportMutability(
else if (_mutability == StateMutability::NonPayable)
{
m_errorReporter.typeError(
8961_error,
_location,
"Function declared as " +
stateMutabilityToString(m_currentFunction->stateMutability()) +
@ -277,12 +280,14 @@ void ViewPureChecker::reportMutability(
{
if (_nestedLocation)
m_errorReporter.typeError(
4006_error,
_location,
SecondarySourceLocation().append("\"msg.value\" or \"callvalue()\" appear here inside the modifier.", *_nestedLocation),
"This modifier uses \"msg.value\" or \"callvalue()\" and thus the function has to be payable or internal."
);
else
m_errorReporter.typeError(
5887_error,
_location,
"\"msg.value\" and \"callvalue()\" can only be used in payable public functions. Make the function "
"\"payable\" or use an internal function to avoid this error."

View File

@ -44,6 +44,7 @@ BMC::BMC(
if (_enabledSolvers.some())
if (!_smtlib2Responses.empty())
m_errorReporter.warning(
5622_error,
"SMT-LIB2 query responses were given in the auxiliary input, "
"but this Solidity binary uses an SMT solver (Z3/CVC4) directly."
"These responses will be ignored."
@ -74,6 +75,7 @@ void BMC::analyze(SourceUnit const& _source, set<Expression const*> _safeAsserti
{
m_noSolverWarning = true;
m_outerErrorReporter.warning(
8084_error,
SourceLocation(),
"BMC analysis was not possible since no integrated SMT solver (Z3 or CVC4) was found."
);
@ -467,6 +469,7 @@ void BMC::internalOrExternalFunctionCall(FunctionCall const& _funCall)
inlineFunctionCall(_funCall);
else if (funType.kind() == FunctionType::Kind::Internal)
m_errorReporter.warning(
5729_error,
_funCall.location(),
"Assertion checker does not yet implement this type of function call."
);
@ -760,6 +763,7 @@ void BMC::checkCondition(
for (auto const& eval: sortedModel)
modelMessage << " " << eval.first << " = " << eval.second << "\n";
m_errorReporter.warning(
4334_error,
_location,
message.str(),
SecondarySourceLocation().append(modelMessage.str(), SourceLocation{})
@ -770,20 +774,20 @@ void BMC::checkCondition(
else
{
message << ".";
m_errorReporter.warning(_location, message.str(), secondaryLocation);
m_errorReporter.warning(6084_error, _location, message.str(), secondaryLocation);
}
break;
}
case smt::CheckResult::UNSATISFIABLE:
break;
case smt::CheckResult::UNKNOWN:
m_errorReporter.warning(_location, _description + " might happen here.", secondaryLocation);
m_errorReporter.warning(5225_error, _location, _description + " might happen here.", secondaryLocation);
break;
case smt::CheckResult::CONFLICTING:
m_errorReporter.warning(_location, "At least two SMT solvers provided conflicting answers. Results might not be sound.");
m_errorReporter.warning(1584_error, _location, "At least two SMT solvers provided conflicting answers. Results might not be sound.");
break;
case smt::CheckResult::ERROR:
m_errorReporter.warning(_location, "Error trying to invoke SMT solver.");
m_errorReporter.warning(1823_error, _location, "Error trying to invoke SMT solver.");
break;
}
@ -813,9 +817,9 @@ void BMC::checkBooleanNotConstant(
m_interface->pop();
if (positiveResult == smt::CheckResult::ERROR || negatedResult == smt::CheckResult::ERROR)
m_errorReporter.warning(_condition.location(), "Error trying to invoke SMT solver.");
m_errorReporter.warning(8592_error, _condition.location(), "Error trying to invoke SMT solver.");
else if (positiveResult == smt::CheckResult::CONFLICTING || negatedResult == smt::CheckResult::CONFLICTING)
m_errorReporter.warning(_condition.location(), "At least two SMT solvers provided conflicting answers. Results might not be sound.");
m_errorReporter.warning(3356_error, _condition.location(), "At least two SMT solvers provided conflicting answers. Results might not be sound.");
else if (positiveResult == smt::CheckResult::SATISFIABLE && negatedResult == smt::CheckResult::SATISFIABLE)
{
// everything fine.
@ -825,7 +829,7 @@ void BMC::checkBooleanNotConstant(
// can't do anything.
}
else if (positiveResult == smt::CheckResult::UNSATISFIABLE && negatedResult == smt::CheckResult::UNSATISFIABLE)
m_errorReporter.warning(_condition.location(), "Condition unreachable.", SMTEncoder::callStackMessage(_callStack));
m_errorReporter.warning(2512_error, _condition.location(), "Condition unreachable.", SMTEncoder::callStackMessage(_callStack));
else
{
string value;
@ -841,6 +845,7 @@ void BMC::checkBooleanNotConstant(
value = "false";
}
m_errorReporter.warning(
6838_error,
_condition.location(),
boost::algorithm::replace_all_copy(_description, "$VALUE", value),
SMTEncoder::callStackMessage(_callStack)
@ -862,7 +867,7 @@ BMC::checkSatisfiableAndGenerateModel(vector<smt::Expression> const& _expression
string description("Error querying SMT solver");
if (_e.comment())
description += ": " + *_e.comment();
m_errorReporter.warning(description);
m_errorReporter.warning(8140_error, description);
result = smt::CheckResult::ERROR;
}

View File

@ -965,10 +965,10 @@ pair<smt::CheckResult, vector<string>> CHC::query(smt::Expression const& _query,
case smt::CheckResult::UNKNOWN:
break;
case smt::CheckResult::CONFLICTING:
m_outerErrorReporter.warning(_location, "At least two SMT solvers provided conflicting answers. Results might not be sound.");
m_outerErrorReporter.warning(1988_error, _location, "At least two SMT solvers provided conflicting answers. Results might not be sound.");
break;
case smt::CheckResult::ERROR:
m_outerErrorReporter.warning(_location, "Error trying to invoke SMT solver.");
m_outerErrorReporter.warning(1218_error, _location, "Error trying to invoke SMT solver.");
break;
}
return {result, values};

View File

@ -266,6 +266,7 @@ void SMTEncoder::endVisit(FunctionDefinition const&)
bool SMTEncoder::visit(InlineAssembly const& _inlineAsm)
{
m_errorReporter.warning(
7737_error,
_inlineAsm.location(),
"Assertion checker does not support inline assembly."
);
@ -325,6 +326,7 @@ void SMTEncoder::endVisit(VariableDeclarationStatement const& _varDecl)
}
else
m_errorReporter.warning(
7186_error,
_varDecl.location(),
"Assertion checker does not yet implement such variable declarations."
);
@ -350,6 +352,7 @@ void SMTEncoder::endVisit(Assignment const& _assignment)
m_context.newValue(*varDecl);
m_errorReporter.warning(
9149_error,
_assignment.location(),
"Assertion checker does not yet implement this assignment operator."
);
@ -409,6 +412,7 @@ void SMTEncoder::endVisit(TupleExpression const& _tuple)
if (_tuple.isInlineArray())
m_errorReporter.warning(
2177_error,
_tuple.location(),
"Assertion checker does not yet implement inline arrays."
);
@ -493,6 +497,7 @@ void SMTEncoder::endVisit(UnaryOperation const& _op)
}
else
m_errorReporter.warning(
1950_error,
_op.location(),
"Assertion checker does not yet implement such increments / decrements."
);
@ -522,6 +527,7 @@ void SMTEncoder::endVisit(UnaryOperation const& _op)
arrayIndexAssignment(_op.subExpression(), symbVar->currentValue());
else
m_errorReporter.warning(
2683_error,
_op.location(),
"Assertion checker does not yet implement \"delete\" for this expression."
);
@ -530,6 +536,7 @@ void SMTEncoder::endVisit(UnaryOperation const& _op)
}
default:
m_errorReporter.warning(
3682_error,
_op.location(),
"Assertion checker does not yet implement this operator."
);
@ -568,6 +575,7 @@ void SMTEncoder::endVisit(BinaryOperation const& _op)
compareOperation(_op);
else
m_errorReporter.warning(
3876_error,
_op.location(),
"Assertion checker does not yet implement this operator."
);
@ -580,6 +588,7 @@ void SMTEncoder::endVisit(FunctionCall const& _funCall)
if (_funCall.annotation().kind == FunctionCallKind::StructConstructorCall)
{
m_errorReporter.warning(
4639_error,
_funCall.location(),
"Assertion checker does not yet implement this expression."
);
@ -639,6 +648,7 @@ void SMTEncoder::endVisit(FunctionCall const& _funCall)
}
default:
m_errorReporter.warning(
4588_error,
_funCall.location(),
"Assertion checker does not yet implement this type of function call."
);
@ -771,6 +781,7 @@ void SMTEncoder::visitTypeConversion(FunctionCall const& _funCall)
}
m_errorReporter.warning(
5084_error,
_funCall.location(),
"Type conversion is not yet fully supported and might yield false positives."
);
@ -800,6 +811,7 @@ void SMTEncoder::endVisit(Literal const& _literal)
else
{
m_errorReporter.warning(
7885_error,
_literal.location(),
"Assertion checker does not yet support the type of this literal (" +
_literal.annotation().type->toString() +
@ -850,6 +862,7 @@ bool SMTEncoder::visit(MemberAccess const& _memberAccess)
accessedName = identifier->name();
else
m_errorReporter.warning(
9551_error,
_memberAccess.location(),
"Assertion checker does not yet support this expression."
);
@ -879,6 +892,7 @@ bool SMTEncoder::visit(MemberAccess const& _memberAccess)
}
else
m_errorReporter.warning(
7650_error,
_memberAccess.location(),
"Assertion checker does not yet support this expression."
);
@ -903,6 +917,7 @@ void SMTEncoder::endVisit(IndexAccess const& _indexAccess)
if (varDecl->type()->category() == Type::Category::FixedBytes)
{
m_errorReporter.warning(
7989_error,
_indexAccess.location(),
"Assertion checker does not yet support index accessing fixed bytes."
);
@ -917,6 +932,7 @@ void SMTEncoder::endVisit(IndexAccess const& _indexAccess)
else
{
m_errorReporter.warning(
9118_error,
_indexAccess.location(),
"Assertion checker does not yet implement this expression."
);
@ -940,6 +956,7 @@ void SMTEncoder::endVisit(IndexRangeAccess const& _indexRangeAccess)
{
createExpr(_indexRangeAccess);
m_errorReporter.warning(
2923_error,
_indexRangeAccess.location(),
"Assertion checker does not yet implement this expression."
);
@ -1019,6 +1036,7 @@ void SMTEncoder::arrayIndexAssignment(Expression const& _expr, smt::Expression c
else
{
m_errorReporter.warning(
9056_error,
_expr.location(),
"Assertion checker does not yet implement this expression."
);
@ -1034,6 +1052,7 @@ void SMTEncoder::defineGlobalVariable(string const& _name, Expression const& _ex
bool abstract = m_context.createGlobalSymbol(_name, _expr);
if (abstract)
m_errorReporter.warning(
1695_error,
_expr.location(),
"Assertion checker does not yet support this global variable."
);
@ -1087,6 +1106,7 @@ void SMTEncoder::arithmeticOperation(BinaryOperation const& _op)
}
default:
m_errorReporter.warning(
5188_error,
_op.location(),
"Assertion checker does not yet implement this operator."
);
@ -1094,6 +1114,7 @@ void SMTEncoder::arithmeticOperation(BinaryOperation const& _op)
}
else
m_errorReporter.warning(
9011_error,
_op.location(),
"Assertion checker does not yet implement this operator for type " + type->richIdentifier() + "."
);
@ -1185,6 +1206,7 @@ void SMTEncoder::compareOperation(BinaryOperation const& _op)
}
else
m_errorReporter.warning(
7229_error,
_op.location(),
"Assertion checker does not yet implement the type " + _op.annotation().commonType->toString() + " for comparisons"
);
@ -1213,6 +1235,7 @@ void SMTEncoder::booleanOperation(BinaryOperation const& _op)
}
else
m_errorReporter.warning(
3263_error,
_op.location(),
"Assertion checker does not yet implement the type " + _op.annotation().commonType->toString() + " for boolean operations"
);
@ -1245,6 +1268,7 @@ void SMTEncoder::assignment(
m_context.newValue(*varDecl);
m_errorReporter.warning(
6191_error,
_location,
"Assertion checker does not yet implement type " + _type->toString()
);
@ -1272,6 +1296,7 @@ void SMTEncoder::assignment(
}
else
m_errorReporter.warning(
8182_error,
_location,
"Assertion checker does not yet implement such assignments."
);
@ -1482,6 +1507,7 @@ bool SMTEncoder::createVariable(VariableDeclaration const& _varDecl)
if (abstract)
{
m_errorReporter.warning(
8115_error,
_varDecl.location(),
"Assertion checker does not yet support the type of this variable."
);
@ -1494,7 +1520,7 @@ smt::Expression SMTEncoder::expr(Expression const& _e, TypePointer _targetType)
{
if (!m_context.knownExpression(_e))
{
m_errorReporter.warning(_e.location(), "Internal error: Expression undefined for SMT solver." );
m_errorReporter.warning(6031_error, _e.location(), "Internal error: Expression undefined for SMT solver." );
createExpr(_e);
}
@ -1506,6 +1532,7 @@ void SMTEncoder::createExpr(Expression const& _e)
bool abstract = m_context.createExpression(_e);
if (abstract)
m_errorReporter.warning(
8364_error,
_e.location(),
"Assertion checker does not yet implement type " + _e.annotation().type->toString()
);

View File

@ -239,7 +239,7 @@ bool CompilerStack::parse()
m_errorReporter.clear();
if (SemVerVersion{string(VersionString)}.isPrerelease())
m_errorReporter.warning("This is a pre-release compiler version, please do not use it in production.");
m_errorReporter.warning(3805_error, "This is a pre-release compiler version, please do not use it in production.");
Parser parser{m_errorReporter, m_evmVersion, m_parserErrorRecovery};
@ -949,6 +949,7 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string
else
{
m_errorReporter.parserError(
6275_error,
import->location(),
string("Source \"" + importPath + "\" not found: " + result.responseOrErrorMessage)
);
@ -1110,6 +1111,7 @@ void CompilerStack::compileContract(
compiledContract.runtimeObject.bytecode.size() > 0x6000
)
m_errorReporter.warning(
5574_error,
_contract.location(),
"Contract code size exceeds 24576 bytes (a limit introduced in Spurious Dragon). "
"This contract may not be deployable on mainnet. "

View File

@ -195,5 +195,5 @@ void DocStringParser::newTag(string const& _tagName)
void DocStringParser::appendError(string const& _description)
{
m_errorsOccurred = true;
m_errorReporter->docstringParsingError(_description);
m_errorReporter->docstringParsingError(9440_error, _description);
}

View File

@ -128,6 +128,7 @@ void Parser::parsePragmaVersion(SourceLocation const& _location, vector<Token> c
// so we don't need to report anything here.
if (!m_parserErrorRecovery)
m_errorReporter.fatalParserError(
5333_error,
_location,
"Source file requires different compiler version (current compiler is " +
string(VersionString) + ") - note that nightly builds are considered to be "

View File

@ -583,6 +583,7 @@ bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation
)
{
m_errorReporter.error(
4316_error,
Error::Type::SyntaxError,
_location,
"Jump instructions and labels are low-level EVM features that can lead to "
@ -599,13 +600,13 @@ bool AsmAnalyzer::warnOnInstructions(evmasm::Instruction _instr, SourceLocation
void AsmAnalyzer::typeError(SourceLocation const& _location, string const& _description)
{
m_errorReporter.typeError(_location, _description);
m_errorReporter.typeError(7569_error, _location, _description);
m_success = false;
}
void AsmAnalyzer::declarationError(SourceLocation const& _location, string const& _description)
{
m_errorReporter.declarationError(_location, _description);
m_errorReporter.declarationError(9595_error, _location, _description);
m_success = false;
}

View File

@ -151,7 +151,7 @@ Statement Parser::parseStatement()
{
Statement stmt{createWithLocation<Leave>()};
if (!m_insideFunction)
m_errorReporter.syntaxError(currentLocation(), "Keyword \"leave\" can only be used inside a function.");
m_errorReporter.syntaxError(8149_error, currentLocation(), "Keyword \"leave\" can only be used inside a function.");
m_scanner->next();
return stmt;
}
@ -417,6 +417,7 @@ FunctionDefinition Parser::parseFunctionDefinition()
if (m_currentForLoopComponent == ForLoopComponent::ForLoopPre)
m_errorReporter.syntaxError(
3441_error,
currentLocation(),
"Functions cannot be defined inside a for-loop init block."
);
@ -534,13 +535,13 @@ void Parser::checkBreakContinuePosition(string const& _which)
switch (m_currentForLoopComponent)
{
case ForLoopComponent::None:
m_errorReporter.syntaxError(currentLocation(), "Keyword \"" + _which + "\" needs to be inside a for-loop body.");
m_errorReporter.syntaxError(2592_error, currentLocation(), "Keyword \"" + _which + "\" needs to be inside a for-loop body.");
break;
case ForLoopComponent::ForLoopPre:
m_errorReporter.syntaxError(currentLocation(), "Keyword \"" + _which + "\" in for-loop init block is not allowed.");
m_errorReporter.syntaxError(9615_error, currentLocation(), "Keyword \"" + _which + "\" in for-loop init block is not allowed.");
break;
case ForLoopComponent::ForLoopPost:
m_errorReporter.syntaxError(currentLocation(), "Keyword \"" + _which + "\" in for-loop post block is not allowed.");
m_errorReporter.syntaxError(2461_error, currentLocation(), "Keyword \"" + _which + "\" in for-loop post block is not allowed.");
break;
case ForLoopComponent::ForLoopBody:
break;

View File

@ -141,6 +141,7 @@ bool ScopeFiller::registerVariable(TypedName const& _name, SourceLocation const&
{
//@TODO secondary location
m_errorReporter.declarationError(
1395_error,
_location,
"Variable name " + _name.name.str() + " already taken in this scope."
);
@ -161,6 +162,7 @@ bool ScopeFiller::registerFunction(FunctionDefinition const& _funDef)
{
//@TODO secondary location
m_errorReporter.declarationError(
6052_error,
_funDef.location,
"Function name " + _funDef.name.str() + " already taken in this scope."
);