Allow global struct definitions.

This commit is contained in:
Daniel Kirchner
2019-09-02 11:17:42 +02:00
parent 25a3a83b34
commit 872d21f527
8 changed files with 47 additions and 5 deletions
+4 -4
View File
@@ -285,17 +285,17 @@ bool CompilerStack::analyze()
// the special variables "this" and "super" must be set appropriately.
for (Source const* source: m_sourceOrder)
for (ASTPointer<ASTNode> const& node: source->ast->nodes())
{
if (!resolver.resolveNamesAndTypes(*node))
return false;
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{
if (!resolver.resolveNamesAndTypes(*contract)) return false;
// Note that we now reference contracts by their fully qualified names, and
// thus contracts can only conflict if declared in the same source file. This
// already causes a double-declaration error elsewhere, so we do not report
// an error here and instead silently drop any additional contracts we find.
if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end())
m_contracts[contract->fullyQualifiedName()].contract = contract;
}
}
// Next, we check inheritance, overrides, function collisions and other things at
// contract or function level.
+4 -1
View File
@@ -96,8 +96,11 @@ ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
case Token::Library:
nodes.push_back(parseContractDefinition());
break;
case Token::Struct:
nodes.push_back(parseStructDefinition());
break;
default:
fatalParserError(string("Expected pragma, import directive or contract/interface/library definition."));
fatalParserError(string("Expected pragma, import directive or contract/interface/library/struct definition."));
}
}
solAssert(m_recursionDepth == 0, "");