mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Assert that visibility of constructor is not queried.
This commit is contained in:
parent
f6232393ef
commit
747aeb4999
@ -558,7 +558,7 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
|||||||
if (auto referenceType = dynamic_cast<ReferenceType const*>(varType))
|
if (auto referenceType = dynamic_cast<ReferenceType const*>(varType))
|
||||||
{
|
{
|
||||||
auto result = referenceType->validForLocation(referenceType->location());
|
auto result = referenceType->validForLocation(referenceType->location());
|
||||||
if (result && _variable.isPublicCallableParameter())
|
if (result && (_variable.isConstructorParameter() || _variable.isPublicCallableParameter()))
|
||||||
result = referenceType->validForLocation(DataLocation::CallData);
|
result = referenceType->validForLocation(DataLocation::CallData);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
@ -288,6 +288,12 @@ bool FunctionDefinition::libraryFunction() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Visibility FunctionDefinition::defaultVisibility() const
|
||||||
|
{
|
||||||
|
solAssert(!isConstructor(), "");
|
||||||
|
return Declaration::defaultVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
|
FunctionTypePointer FunctionDefinition::functionType(bool _internal) const
|
||||||
{
|
{
|
||||||
if (_internal)
|
if (_internal)
|
||||||
@ -623,7 +629,12 @@ set<VariableDeclaration::Location> VariableDeclaration::allowedDataLocations() c
|
|||||||
else if (isCallableOrCatchParameter())
|
else if (isCallableOrCatchParameter())
|
||||||
{
|
{
|
||||||
set<Location> locations{ Location::Memory };
|
set<Location> locations{ Location::Memory };
|
||||||
if (isInternalCallableParameter() || isLibraryFunctionParameter() || isTryCatchParameter())
|
if (
|
||||||
|
isConstructorParameter() ||
|
||||||
|
isInternalCallableParameter() ||
|
||||||
|
isLibraryFunctionParameter() ||
|
||||||
|
isTryCatchParameter()
|
||||||
|
)
|
||||||
locations.insert(Location::Storage);
|
locations.insert(Location::Storage);
|
||||||
if (!isTryCatchParameter() && !isConstructorParameter())
|
if (!isTryCatchParameter() && !isConstructorParameter())
|
||||||
locations.insert(Location::CallData);
|
locations.insert(Location::CallData);
|
||||||
|
@ -806,15 +806,16 @@ public:
|
|||||||
bool isPayable() const { return m_stateMutability == StateMutability::Payable; }
|
bool isPayable() const { return m_stateMutability == StateMutability::Payable; }
|
||||||
std::vector<ASTPointer<ModifierInvocation>> const& modifiers() const { return m_functionModifiers; }
|
std::vector<ASTPointer<ModifierInvocation>> const& modifiers() const { return m_functionModifiers; }
|
||||||
Block const& body() const { solAssert(m_body, ""); return *m_body; }
|
Block const& body() const { solAssert(m_body, ""); return *m_body; }
|
||||||
|
Visibility defaultVisibility() const override;
|
||||||
bool isVisibleInContract() const override
|
bool isVisibleInContract() const override
|
||||||
{
|
{
|
||||||
return Declaration::isVisibleInContract() && isOrdinary();
|
return isOrdinary() && Declaration::isVisibleInContract();
|
||||||
}
|
}
|
||||||
bool isVisibleViaContractTypeAccess() const override
|
bool isVisibleViaContractTypeAccess() const override
|
||||||
{
|
{
|
||||||
return isOrdinary() && visibility() >= Visibility::Public;
|
return isOrdinary() && visibility() >= Visibility::Public;
|
||||||
}
|
}
|
||||||
bool isPartOfExternalInterface() const override { return isPublic() && isOrdinary(); }
|
bool isPartOfExternalInterface() const override { return isOrdinary() && isPublic(); }
|
||||||
|
|
||||||
/// @returns the external signature of the function
|
/// @returns the external signature of the function
|
||||||
/// That consists of the name of the function followed by the types of the
|
/// That consists of the name of the function followed by the types of the
|
||||||
@ -926,6 +927,7 @@ public:
|
|||||||
/// @returns true if this variable is a parameter or return parameter of an internal function
|
/// @returns true if this variable is a parameter or return parameter of an internal function
|
||||||
/// or a function type of internal visibility.
|
/// or a function type of internal visibility.
|
||||||
bool isInternalCallableParameter() const;
|
bool isInternalCallableParameter() const;
|
||||||
|
/// @returns true if this variable is the parameter of a constructor.
|
||||||
bool isConstructorParameter() const;
|
bool isConstructorParameter() const;
|
||||||
/// @returns true iff this variable is a parameter(or return parameter of a library function
|
/// @returns true iff this variable is a parameter(or return parameter of a library function
|
||||||
bool isLibraryFunctionParameter() const;
|
bool isLibraryFunctionParameter() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user