mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow empty import statements
This commit is contained in:
parent
2fc7928697
commit
9aafa32825
@ -1,10 +1,10 @@
|
|||||||
### 0.5.4 (unreleased)
|
### 0.5.4 (unreleased)
|
||||||
|
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
* Parser: Disallow empty import statements.
|
||||||
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
|
* Type system: Properly report packed encoded size for arrays and structs (mostly unused until now).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Language Features:
|
Language Features:
|
||||||
|
|
||||||
|
|
||||||
|
@ -681,6 +681,8 @@ StringMap CompilerStack::loadMissingSources(SourceUnit const& _ast, std::string
|
|||||||
for (auto const& node: _ast.nodes())
|
for (auto const& node: _ast.nodes())
|
||||||
if (ImportDirective const* import = dynamic_cast<ImportDirective*>(node.get()))
|
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);
|
string importPath = dev::absolutePath(import->path(), _sourcePath);
|
||||||
// The current value of `path` is the absolute path as seen from this source file.
|
// 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
|
// We first have to apply remappings before we can store the actual absolute path
|
||||||
|
@ -221,6 +221,8 @@ ASTPointer<ImportDirective> Parser::parseImportDirective()
|
|||||||
fatalParserError("Expected import path.");
|
fatalParserError("Expected import path.");
|
||||||
path = getLiteralAndAdvance();
|
path = getLiteralAndAdvance();
|
||||||
}
|
}
|
||||||
|
if (path->empty())
|
||||||
|
fatalParserError("Import path cannot be empty.");
|
||||||
nodeFactory.markEndPosition();
|
nodeFactory.markEndPosition();
|
||||||
expectToken(Token::Semicolon);
|
expectToken(Token::Semicolon);
|
||||||
return nodeFactory.createNode<ImportDirective>(path, unitAlias, move(symbolAliases));
|
return nodeFactory.createNode<ImportDirective>(path, unitAlias, move(symbolAliases));
|
||||||
|
3
test/libsolidity/syntaxTests/parsing/import_empty.sol
Normal file
3
test/libsolidity/syntaxTests/parsing/import_empty.sol
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import "";
|
||||||
|
// ----
|
||||||
|
// ParserError: (9-10): Import path cannot be empty.
|
Loading…
Reference in New Issue
Block a user