mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Moved a canBeStored assert for struct members to TypeChecker
This is to avoid a assert from failing for forward declared user defined value types.
This commit is contained in:
parent
9428dbc94f
commit
51009c005d
@ -100,7 +100,6 @@ bool DeclarationTypeChecker::visit(StructDefinition const& _struct)
|
|||||||
m_recursiveStructSeen = false;
|
m_recursiveStructSeen = false;
|
||||||
member->accept(*this);
|
member->accept(*this);
|
||||||
solAssert(member->annotation().type, "");
|
solAssert(member->annotation().type, "");
|
||||||
solAssert(member->annotation().type->canBeStored(), "Type cannot be used in struct.");
|
|
||||||
if (m_recursiveStructSeen)
|
if (m_recursiveStructSeen)
|
||||||
hasRecursiveChild = true;
|
hasRecursiveChild = true;
|
||||||
}
|
}
|
||||||
|
@ -621,6 +621,16 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TypeChecker::endVisit(StructDefinition const& _struct)
|
||||||
|
{
|
||||||
|
for (auto const& member: _struct.members())
|
||||||
|
solAssert(
|
||||||
|
member->annotation().type &&
|
||||||
|
member->annotation().type->canBeStored(),
|
||||||
|
"Type cannot be used in struct."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void TypeChecker::visitManually(
|
void TypeChecker::visitManually(
|
||||||
ModifierInvocation const& _modifier,
|
ModifierInvocation const& _modifier,
|
||||||
vector<ContractDefinition const*> const& _bases
|
vector<ContractDefinition const*> const& _bases
|
||||||
|
@ -121,6 +121,7 @@ private:
|
|||||||
bool visit(FunctionDefinition const& _function) override;
|
bool visit(FunctionDefinition const& _function) override;
|
||||||
void endVisit(ArrayTypeName const& _typeName) override;
|
void endVisit(ArrayTypeName const& _typeName) override;
|
||||||
bool visit(VariableDeclaration const& _variable) override;
|
bool visit(VariableDeclaration const& _variable) override;
|
||||||
|
void endVisit(StructDefinition const& _struct) override;
|
||||||
/// We need to do this manually because we want to pass the bases of the current contract in
|
/// We need to do this manually because we want to pass the bases of the current contract in
|
||||||
/// case this is a base constructor call.
|
/// case this is a base constructor call.
|
||||||
void visitManually(ModifierInvocation const& _modifier, std::vector<ContractDefinition const*> const& _bases);
|
void visitManually(ModifierInvocation const& _modifier, std::vector<ContractDefinition const*> const& _bases);
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
struct S { U u; }
|
||||||
|
contract C { S s; }
|
||||||
|
type U is address;
|
Loading…
Reference in New Issue
Block a user