Merge pull request #9023 from ethereum/errorid-random-seed-fix

Fixed seed for randomness, fixed conflicts in errorids
This commit is contained in:
chriseth 2020-05-26 15:17:49 +02:00 committed by GitHub
commit 37aeeb05da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 25 deletions

View File

@ -151,7 +151,7 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName)
{ {
_typeName.annotation().type = TypeProvider::emptyTuple(); _typeName.annotation().type = TypeProvider::emptyTuple();
m_errorReporter.fatalTypeError( m_errorReporter.fatalTypeError(
9755_error, 5172_error,
_typeName.location(), _typeName.location(),
"Name has to refer to a struct, enum or contract." "Name has to refer to a struct, enum or contract."
); );
@ -176,7 +176,7 @@ bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
break; break;
default: default:
m_errorReporter.fatalTypeError( m_errorReporter.fatalTypeError(
7653_error, 6012_error,
_typeName.location(), _typeName.location(),
"Invalid visibility, can only be \"external\" or \"internal\"." "Invalid visibility, can only be \"external\" or \"internal\"."
); );
@ -186,7 +186,7 @@ bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
if (_typeName.isPayable() && _typeName.visibility() != Visibility::External) if (_typeName.isPayable() && _typeName.visibility() != Visibility::External)
{ {
m_errorReporter.fatalTypeError( m_errorReporter.fatalTypeError(
6138_error, 7415_error,
_typeName.location(), _typeName.location(),
"Only external function types can be payable." "Only external function types can be payable."
); );
@ -246,7 +246,7 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
} }
if (baseType->storageBytes() == 0) if (baseType->storageBytes() == 0)
m_errorReporter.fatalTypeError( m_errorReporter.fatalTypeError(
9390_error, 6493_error,
_typeName.baseType().location(), _typeName.baseType().location(),
"Illegal base type of storage size zero for array." "Illegal base type of storage size zero for array."
); );
@ -259,16 +259,16 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
u256 lengthValue = 0; u256 lengthValue = 0;
if (!lengthType || !lengthType->mobileType()) if (!lengthType || !lengthType->mobileType())
m_errorReporter.typeError( m_errorReporter.typeError(
8922_error, 5462_error,
length->location(), length->location(),
"Invalid array length, expected integer literal or constant expression." "Invalid array length, expected integer literal or constant expression."
); );
else if (lengthType->isZero()) else if (lengthType->isZero())
m_errorReporter.typeError(1220_error, length->location(), "Array with zero length specified."); m_errorReporter.typeError(1406_error, length->location(), "Array with zero length specified.");
else if (lengthType->isFractional()) else if (lengthType->isFractional())
m_errorReporter.typeError(4323_error, length->location(), "Array with fractional length specified."); m_errorReporter.typeError(3208_error, length->location(), "Array with fractional length specified.");
else if (lengthType->isNegative()) else if (lengthType->isNegative())
m_errorReporter.typeError(9308_error, length->location(), "Array with negative length specified."); m_errorReporter.typeError(3658_error, length->location(), "Array with negative length specified.");
else else
lengthValue = lengthType->literalValue(nullptr); lengthValue = lengthType->literalValue(nullptr);
_typeName.annotation().type = TypeProvider::array(DataLocation::Storage, baseType, lengthValue); _typeName.annotation().type = TypeProvider::array(DataLocation::Storage, baseType, lengthValue);
@ -345,7 +345,7 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
errorString += " for variable"; errorString += " for variable";
} }
errorString += ", but " + locationToString(varLoc) + " was given."; errorString += ", but " + locationToString(varLoc) + " was given.";
m_errorReporter.typeError(6160_error, _variable.location(), errorString); m_errorReporter.typeError(6651_error, _variable.location(), errorString);
solAssert(!allowedDataLocations.empty(), ""); solAssert(!allowedDataLocations.empty(), "");
varLoc = *allowedDataLocations.begin(); varLoc = *allowedDataLocations.begin();

View File

@ -559,7 +559,7 @@ void OverrideChecker::checkOverride(OverrideProxy const& _overriding, OverridePr
overrideError( overrideError(
_overriding, _overriding,
_super, _super,
2837_error, 6959_error,
"Overriding function changes state mutability from \"" + "Overriding function changes state mutability from \"" +
stateMutabilityToString(_super.stateMutability()) + stateMutabilityToString(_super.stateMutability()) +
"\" to \"" + "\" to \"" +

View File

@ -119,7 +119,7 @@ bool ReferencesResolver::visit(Identifier const& _identifier)
else else
errorMessage += " Did you mean " + std::move(suggestions) + "?"; errorMessage += " Did you mean " + std::move(suggestions) + "?";
} }
m_errorReporter.declarationError(8051_error, _identifier.location(), errorMessage); m_errorReporter.declarationError(7576_error, _identifier.location(), errorMessage);
} }
else if (declarations.size() == 1) else if (declarations.size() == 1)
_identifier.annotation().referencedDeclaration = declarations.front(); _identifier.annotation().referencedDeclaration = declarations.front();
@ -157,7 +157,7 @@ void ReferencesResolver::endVisit(UserDefinedTypeName const& _typeName)
Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath()); Declaration const* declaration = m_resolver.pathFromCurrentScope(_typeName.namePath());
if (!declaration) if (!declaration)
{ {
m_errorReporter.fatalDeclarationError(7556_error, _typeName.location(), "Identifier not found or not unique."); m_errorReporter.fatalDeclarationError(7920_error, _typeName.location(), "Identifier not found or not unique.");
return; return;
} }
@ -210,7 +210,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
if (realName.empty()) if (realName.empty())
{ {
m_errorReporter.declarationError( m_errorReporter.declarationError(
9553_error, 4794_error,
_identifier.location, _identifier.location,
"In variable names _slot and _offset can only be used as a suffix." "In variable names _slot and _offset can only be used as a suffix."
); );
@ -221,7 +221,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
if (declarations.size() > 1) if (declarations.size() > 1)
{ {
m_errorReporter.declarationError( m_errorReporter.declarationError(
8827_error, 4718_error,
_identifier.location, _identifier.location,
"Multiple matching identifiers. Resolving overloaded identifiers is not supported." "Multiple matching identifiers. Resolving overloaded identifiers is not supported."
); );
@ -233,7 +233,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
if (var->isLocalVariable() && m_yulInsideFunction) if (var->isLocalVariable() && m_yulInsideFunction)
{ {
m_errorReporter.declarationError( m_errorReporter.declarationError(
8477_error, 6578_error,
_identifier.location, _identifier.location,
"Cannot access local Solidity variables from inside an inline assembly function." "Cannot access local Solidity variables from inside an inline assembly function."
); );
@ -255,7 +255,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.')); string namePrefix = identifier.name.str().substr(0, identifier.name.str().find('.'));
if (isSlot || isOffset) if (isSlot || isOffset)
m_errorReporter.declarationError( m_errorReporter.declarationError(
8820_error, 9155_error,
identifier.location, identifier.location,
"In variable declarations _slot and _offset can not be used as a suffix." "In variable declarations _slot and _offset can not be used as a suffix."
); );
@ -269,7 +269,7 @@ void ReferencesResolver::operator()(yul::VariableDeclaration const& _varDecl)
ssl.append("The shadowed declaration is here:", decl->location()); ssl.append("The shadowed declaration is here:", decl->location());
if (!ssl.infos.empty()) if (!ssl.infos.empty())
m_errorReporter.declarationError( m_errorReporter.declarationError(
6005_error, 3859_error,
identifier.location, identifier.location,
ssl, ssl,
namePrefix.size() < identifier.name.str().size() ? namePrefix.size() < identifier.name.str().size() ?

View File

@ -2611,7 +2611,7 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
auto const* var = dynamic_cast<Identifier const*>(&_memberAccess.expression()); auto const* var = dynamic_cast<Identifier const*>(&_memberAccess.expression());
string varName = var ? var->name() : "..."; string varName = var ? var->name() : "...";
errorMsg += " Use \"address(" + varName + ")." + memberName + "\" to access this address member."; errorMsg += " Use \"address(" + varName + ")." + memberName + "\" to access this address member.";
return { 5256_error, errorMsg }; return { 3125_error, errorMsg };
} }
} }
else if (auto const* addressType = dynamic_cast<AddressType const*>(exprType)) else if (auto const* addressType = dynamic_cast<AddressType const*>(exprType))
@ -2624,11 +2624,11 @@ bool TypeChecker::visit(MemberAccess const& _memberAccess)
"Expected address not-payable as members were not found" "Expected address not-payable as members were not found"
); );
return { 2604_error, "\"send\" and \"transfer\" are only available for objects of type \"address payable\", not \"" + exprType->toString() + "\"." }; return { 9862_error, "\"send\" and \"transfer\" are only available for objects of type \"address payable\", not \"" + exprType->toString() + "\"." };
} }
} }
return { 5856_error, errorMsg }; return { 9582_error, errorMsg };
}(); }();
m_errorReporter.fatalTypeError( m_errorReporter.fatalTypeError(
@ -2904,7 +2904,7 @@ bool TypeChecker::visit(IndexRangeAccess const& _access)
if (arrayType->location() != DataLocation::CallData || !arrayType->isDynamicallySized()) if (arrayType->location() != DataLocation::CallData || !arrayType->isDynamicallySized())
m_errorReporter.typeError(1227_error, _access.location(), "Index range access is only supported for dynamic calldata arrays."); m_errorReporter.typeError(1227_error, _access.location(), "Index range access is only supported for dynamic calldata arrays.");
else if (arrayType->baseType()->isDynamicallyEncoded()) else if (arrayType->baseType()->isDynamicallyEncoded())
m_errorReporter.typeError(1878_error, _access.location(), "Index range access is not supported for arrays with dynamically encoded base types."); m_errorReporter.typeError(2148_error, _access.location(), "Index range access is not supported for arrays with dynamically encoded base types.");
_access.annotation().type = TypeProvider::arraySlice(*arrayType); _access.annotation().type = TypeProvider::arraySlice(*arrayType);
_access.annotation().isLValue = isLValue; _access.annotation().isLValue = isLValue;
_access.annotation().isPure = isPure; _access.annotation().isPure = isPure;
@ -3203,10 +3203,10 @@ void TypeChecker::requireLValue(Expression const& _expression, bool _ordinaryAss
if (auto indexAccess = dynamic_cast<IndexAccess const*>(&_expression)) if (auto indexAccess = dynamic_cast<IndexAccess const*>(&_expression))
{ {
if (type(indexAccess->baseExpression())->category() == Type::Category::FixedBytes) if (type(indexAccess->baseExpression())->category() == Type::Category::FixedBytes)
return { 9222_error, "Single bytes in fixed bytes arrays cannot be modified." }; return { 4360_error, "Single bytes in fixed bytes arrays cannot be modified." };
else if (auto arrayType = dynamic_cast<ArrayType const*>(type(indexAccess->baseExpression()))) else if (auto arrayType = dynamic_cast<ArrayType const*>(type(indexAccess->baseExpression())))
if (arrayType->dataStoredIn(DataLocation::CallData)) if (arrayType->dataStoredIn(DataLocation::CallData))
return { 3335_error, "Calldata arrays are read-only." }; return { 6182_error, "Calldata arrays are read-only." };
} }
if (auto memberAccess = dynamic_cast<MemberAccess const*>(&_expression)) if (auto memberAccess = dynamic_cast<MemberAccess const*>(&_expression))
@ -3214,7 +3214,7 @@ void TypeChecker::requireLValue(Expression const& _expression, bool _ordinaryAss
if (auto structType = dynamic_cast<StructType const*>(type(memberAccess->expression()))) if (auto structType = dynamic_cast<StructType const*>(type(memberAccess->expression())))
{ {
if (structType->dataStoredIn(DataLocation::CallData)) if (structType->dataStoredIn(DataLocation::CallData))
return { 9942_error, "Calldata structs are read-only." }; return { 4156_error, "Calldata structs are read-only." };
} }
else if (dynamic_cast<ArrayType const*>(type(memberAccess->expression()))) else if (dynamic_cast<ArrayType const*>(type(memberAccess->expression())))
if (memberAccess->memberName() == "length") if (memberAccess->memberName() == "length")

View File

@ -55,7 +55,6 @@ def get_used_ids(file_names):
def get_id(available_ids, used_ids): def get_id(available_ids, used_ids):
while len(available_ids) > 0: while len(available_ids) > 0:
random.seed(len(available_ids))
k = random.randrange(len(available_ids)) k = random.randrange(len(available_ids))
id = list(available_ids.keys())[k] id = list(available_ids.keys())[k]
del available_ids[id] del available_ids[id]
@ -117,6 +116,7 @@ def find_source_files(top_dir):
def main(): def main():
random.seed()
cwd = os.getcwd() cwd = os.getcwd()
answer = input( answer = input(
f"This script checks and corrects *_error literals in .h and .cpp files\n" f"This script checks and corrects *_error literals in .h and .cpp files\n"