Merge pull request #5867 from ethereum/empty-import

Disallow empty import statements
This commit is contained in:
chriseth 2019-01-28 15:07:24 +01:00 committed by GitHub
commit 71a8e2b70e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 1 deletions

View File

@ -1,10 +1,10 @@
### 0.5.4 (unreleased)
Bugfixes:
* Parser: Disallow empty import statements.
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
Language Features:

View File

@ -681,6 +681,8 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string
for (auto const& node: _ast.nodes())
if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get()))
{
solAssert(!import->path().empty(), "Import path cannot be empty.");
string importPath = dev::absolutePath(import->path(), _sourcePath);
// The current value of `path` is the absolute path as seen from this source file.
// We first have to apply remappings before we can store the actual absolute path

View File

@ -221,6 +221,8 @@ ASTPointer<ImportDirective> Parser::parseImportDirective()
fatalParserError("Expected import path.");
path = getLiteralAndAdvance();
}
if (path->empty())
fatalParserError("Import path cannot be empty.");
nodeFactory.markEndPosition();
expectToken(Token::Semicolon);
return nodeFactory.createNode<ImportDirective>(path, unitAlias, move(symbolAliases));

View File

@ -0,0 +1,3 @@
import "";
// ----
// ParserError: (9-10): Import path cannot be empty.