mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Shorten a couple of lines
This commit is contained in:
parent
38e65a909a
commit
5870253b00
@ -103,7 +103,11 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct)
|
|||||||
auto visitor = [&](StructDefinition const& _struct, auto& _cycleDetector, size_t _depth)
|
auto visitor = [&](StructDefinition const& _struct, auto& _cycleDetector, size_t _depth)
|
||||||
{
|
{
|
||||||
if (_depth >= 256)
|
if (_depth >= 256)
|
||||||
m_errorReporter.fatalDeclarationError(5651_error, _struct.location(), "Struct definition exhausts cyclic dependency validator.");
|
m_errorReporter.fatalDeclarationError(
|
||||||
|
5651_error,
|
||||||
|
_struct.location(),
|
||||||
|
"Struct definition exhausts cyclic dependency validator."
|
||||||
|
);
|
||||||
|
|
||||||
for (ASTPointer<VariableDeclaration> const& member: _struct.members())
|
for (ASTPointer<VariableDeclaration> const& member: _struct.members())
|
||||||
{
|
{
|
||||||
@ -146,9 +150,14 @@ void DeclarationTypeChecker::endVisit(UserDefinedTypeName const& _typeName)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_typeName.annotation().type = TypeProvider::emptyTuple();
|
_typeName.annotation().type = TypeProvider::emptyTuple();
|
||||||
m_errorReporter.fatalTypeError(9755_error, _typeName.location(), "Name has to refer to a struct, enum or contract.");
|
m_errorReporter.fatalTypeError(
|
||||||
|
9755_error,
|
||||||
|
_typeName.location(),
|
||||||
|
"Name has to refer to a struct, enum or contract."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
|
bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
|
||||||
{
|
{
|
||||||
if (_typeName.annotation().type)
|
if (_typeName.annotation().type)
|
||||||
@ -166,18 +175,27 @@ bool DeclarationTypeChecker::visit(FunctionTypeName const& _typeName)
|
|||||||
case Visibility::External:
|
case Visibility::External:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_errorReporter.fatalTypeError(7653_error, _typeName.location(), "Invalid visibility, can only be \"external\" or \"internal\".");
|
m_errorReporter.fatalTypeError(
|
||||||
|
7653_error,
|
||||||
|
_typeName.location(),
|
||||||
|
"Invalid visibility, can only be \"external\" or \"internal\"."
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_typeName.isPayable() && _typeName.visibility() != Visibility::External)
|
if (_typeName.isPayable() && _typeName.visibility() != Visibility::External)
|
||||||
{
|
{
|
||||||
m_errorReporter.fatalTypeError(6138_error, _typeName.location(), "Only external function types can be payable.");
|
m_errorReporter.fatalTypeError(
|
||||||
|
6138_error,
|
||||||
|
_typeName.location(),
|
||||||
|
"Only external function types can be payable."
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_typeName.annotation().type = TypeProvider::function(_typeName);
|
_typeName.annotation().type = TypeProvider::function(_typeName);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
|
void DeclarationTypeChecker::endVisit(Mapping const& _mapping)
|
||||||
{
|
{
|
||||||
if (_mapping.annotation().type)
|
if (_mapping.annotation().type)
|
||||||
@ -227,7 +245,11 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (baseType->storageBytes() == 0)
|
if (baseType->storageBytes() == 0)
|
||||||
m_errorReporter.fatalTypeError(9390_error, _typeName.baseType().location(), "Illegal base type of storage size zero for array.");
|
m_errorReporter.fatalTypeError(
|
||||||
|
9390_error,
|
||||||
|
_typeName.baseType().location(),
|
||||||
|
"Illegal base type of storage size zero for array."
|
||||||
|
);
|
||||||
if (Expression const* length = _typeName.length())
|
if (Expression const* length = _typeName.length())
|
||||||
{
|
{
|
||||||
TypePointer& lengthTypeGeneric = length->annotation().type;
|
TypePointer& lengthTypeGeneric = length->annotation().type;
|
||||||
@ -236,7 +258,11 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
|
|||||||
RationalNumberType const* lengthType = dynamic_cast<RationalNumberType const*>(lengthTypeGeneric);
|
RationalNumberType const* lengthType = dynamic_cast<RationalNumberType const*>(lengthTypeGeneric);
|
||||||
u256 lengthValue = 0;
|
u256 lengthValue = 0;
|
||||||
if (!lengthType || !lengthType->mobileType())
|
if (!lengthType || !lengthType->mobileType())
|
||||||
m_errorReporter.typeError(8922_error, length->location(), "Invalid array length, expected integer literal or constant expression.");
|
m_errorReporter.typeError(
|
||||||
|
8922_error,
|
||||||
|
length->location(),
|
||||||
|
"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(1220_error, length->location(), "Array with zero length specified.");
|
||||||
else if (lengthType->isFractional())
|
else if (lengthType->isFractional())
|
||||||
@ -250,15 +276,24 @@ void DeclarationTypeChecker::endVisit(ArrayTypeName const& _typeName)
|
|||||||
else
|
else
|
||||||
_typeName.annotation().type = TypeProvider::array(DataLocation::Storage, baseType);
|
_typeName.annotation().type = TypeProvider::array(DataLocation::Storage, baseType);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
|
void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
|
||||||
{
|
{
|
||||||
if (_variable.annotation().type)
|
if (_variable.annotation().type)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_variable.isConstant() && !_variable.isStateVariable())
|
if (_variable.isConstant() && !_variable.isStateVariable())
|
||||||
m_errorReporter.declarationError(1788_error, _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())
|
if (_variable.immutable() && !_variable.isStateVariable())
|
||||||
m_errorReporter.declarationError(8297_error, _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())
|
if (!_variable.typeName())
|
||||||
{
|
{
|
||||||
|
@ -69,13 +69,15 @@ bool DocStringAnalyser::visit(VariableDeclaration const& _variable)
|
|||||||
if (_variable.annotation().docTags.count("notice") > 0)
|
if (_variable.annotation().docTags.count("notice") > 0)
|
||||||
m_errorReporter.warning(
|
m_errorReporter.warning(
|
||||||
7816_error, _variable.documentation()->location(),
|
7816_error, _variable.documentation()->location(),
|
||||||
"Documentation tag on non-public state variables will be disallowed in 0.7.0. You will need to use the @dev tag explicitly."
|
"Documentation tag on non-public state variables will be disallowed in 0.7.0. "
|
||||||
|
"You will need to use the @dev tag explicitly."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0)
|
if (_variable.annotation().docTags.count("title") > 0 || _variable.annotation().docTags.count("author") > 0)
|
||||||
m_errorReporter.warning(
|
m_errorReporter.warning(
|
||||||
8532_error, _variable.documentation()->location(),
|
8532_error, _variable.documentation()->location(),
|
||||||
"Documentation tag @title and @author is only allowed on contract definitions. It will be disallowed in 0.7.0."
|
"Documentation tag @title and @author is only allowed on contract definitions. "
|
||||||
|
"It will be disallowed in 0.7.0."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -209,14 +209,22 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
|
|||||||
));
|
));
|
||||||
if (realName.empty())
|
if (realName.empty())
|
||||||
{
|
{
|
||||||
m_errorReporter.declarationError(9553_error, _identifier.location, "In variable names _slot and _offset can only be used as a suffix.");
|
m_errorReporter.declarationError(
|
||||||
|
9553_error,
|
||||||
|
_identifier.location,
|
||||||
|
"In variable names _slot and _offset can only be used as a suffix."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
declarations = m_resolver.nameFromCurrentScope(realName);
|
declarations = m_resolver.nameFromCurrentScope(realName);
|
||||||
}
|
}
|
||||||
if (declarations.size() > 1)
|
if (declarations.size() > 1)
|
||||||
{
|
{
|
||||||
m_errorReporter.declarationError(8827_error, _identifier.location, "Multiple matching identifiers. Resolving overloaded identifiers is not supported.");
|
m_errorReporter.declarationError(
|
||||||
|
8827_error,
|
||||||
|
_identifier.location,
|
||||||
|
"Multiple matching identifiers. Resolving overloaded identifiers is not supported."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (declarations.size() == 0)
|
else if (declarations.size() == 0)
|
||||||
@ -224,7 +232,11 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier)
|
|||||||
if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front()))
|
if (auto var = dynamic_cast<VariableDeclaration const*>(declarations.front()))
|
||||||
if (var->isLocalVariable() && m_yulInsideFunction)
|
if (var->isLocalVariable() && m_yulInsideFunction)
|
||||||
{
|
{
|
||||||
m_errorReporter.declarationError(8477_error, _identifier.location, "Cannot access local Solidity variables from inside an inline assembly function.");
|
m_errorReporter.declarationError(
|
||||||
|
8477_error,
|
||||||
|
_identifier.location,
|
||||||
|
"Cannot access local Solidity variables from inside an inline assembly function."
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +254,11 @@ 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(8820_error, identifier.location, "In variable declarations _slot and _offset can not be used as a suffix.");
|
m_errorReporter.declarationError(
|
||||||
|
8820_error,
|
||||||
|
identifier.location,
|
||||||
|
"In variable declarations _slot and _offset can not be used as a suffix."
|
||||||
|
);
|
||||||
else if (
|
else if (
|
||||||
auto declarations = m_resolver.nameFromCurrentScope(namePrefix);
|
auto declarations = m_resolver.nameFromCurrentScope(namePrefix);
|
||||||
!declarations.empty()
|
!declarations.empty()
|
||||||
|
@ -96,7 +96,10 @@ void DocStringParser::parse(string const& _docString, ErrorReporter& _errorRepor
|
|||||||
auto tagNameEndPos = firstWhitespaceOrNewline(tagPos, end);
|
auto tagNameEndPos = firstWhitespaceOrNewline(tagPos, end);
|
||||||
if (tagNameEndPos == end)
|
if (tagNameEndPos == end)
|
||||||
{
|
{
|
||||||
m_errorReporter->docstringParsingError(9222_error, "End of tag " + string(tagPos, tagNameEndPos) + " not found");
|
m_errorReporter->docstringParsingError(
|
||||||
|
9222_error,
|
||||||
|
"End of tag " + string(tagPos, tagNameEndPos) + " not found"
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user