mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Check that there is an interface type before querying validity of location.
This commit is contained in:
parent
58e0977647
commit
e87cd0afdf
@ -583,13 +583,18 @@ 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());
|
BoolResult result = referenceType->validForLocation(referenceType->location());
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
bool isLibraryStorageParameter = (_variable.isLibraryFunctionParameter() && referenceType->location() == DataLocation::Storage);
|
bool isLibraryStorageParameter = (_variable.isLibraryFunctionParameter() && referenceType->location() == DataLocation::Storage);
|
||||||
bool callDataCheckRequired = ((_variable.isConstructorParameter() || _variable.isPublicCallableParameter()) && !isLibraryStorageParameter);
|
bool callDataCheckRequired = ((_variable.isConstructorParameter() || _variable.isPublicCallableParameter()) && !isLibraryStorageParameter);
|
||||||
if (callDataCheckRequired)
|
if (callDataCheckRequired)
|
||||||
result = referenceType->validForLocation(DataLocation::CallData);
|
{
|
||||||
|
if (!referenceType->interfaceType(false))
|
||||||
|
solAssert(m_errorReporter.hasErrors(), "");
|
||||||
|
else
|
||||||
|
result = referenceType->validForLocation(DataLocation::CallData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
|
@ -769,6 +769,8 @@ public:
|
|||||||
bool isPointer() const;
|
bool isPointer() const;
|
||||||
|
|
||||||
/// @returns true if this is valid to be stored in data location _loc
|
/// @returns true if this is valid to be stored in data location _loc
|
||||||
|
/// The function mostly checks sizes. For calldata, this should only be called
|
||||||
|
/// if the type has an interfaceType.
|
||||||
virtual BoolResult validForLocation(DataLocation _loc) const = 0;
|
virtual BoolResult validForLocation(DataLocation _loc) const = 0;
|
||||||
|
|
||||||
bool operator==(ReferenceType const& _other) const
|
bool operator==(ReferenceType const& _other) const
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
struct S { function() internal a; }
|
||||||
|
function f(S[2] memory) public {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4103: (89-100): Internal type is not allowed for public or external functions.
|
@ -0,0 +1,8 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
struct S { function() internal[2] a; }
|
||||||
|
function f(S memory) public {}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// TypeError 4103: (92-100): Internal type is not allowed for public or external functions.
|
Loading…
Reference in New Issue
Block a user