mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disallow empty structs
This commit is contained in:
parent
62559cf127
commit
b540ba527a
@ -12,6 +12,7 @@ Bugfixes:
|
||||
* Commandline interface: Support ``--evm-version constantinople`` properly.
|
||||
* DocString Parser: Fix error message for empty descriptions.
|
||||
* Standard JSON: Support ``constantinople`` as ``evmVersion`` properly.
|
||||
* Syntax Checker: Issue error for empty structs.
|
||||
* Type System: Make external library functions accessible.
|
||||
|
||||
### 0.4.21 (2018-03-07)
|
||||
|
@ -19,7 +19,7 @@ InheritanceSpecifier = UserDefinedTypeName ( '(' Expression ( ',' Expression )*
|
||||
StateVariableDeclaration = TypeName ( 'public' | 'internal' | 'private' | 'constant' )? Identifier ('=' Expression)? ';'
|
||||
UsingForDeclaration = 'using' Identifier 'for' ('*' | TypeName) ';'
|
||||
StructDefinition = 'struct' Identifier '{'
|
||||
( VariableDeclaration ';' (VariableDeclaration ';')* )? '}'
|
||||
( VariableDeclaration ';' (VariableDeclaration ';')* ) '}'
|
||||
|
||||
ModifierDefinition = 'modifier' Identifier ParameterList? Block
|
||||
ModifierInvocation = Identifier ( '(' ExpressionList? ')' )?
|
||||
|
@ -255,3 +255,10 @@ bool SyntaxChecker::visit(VariableDeclaration const& _declaration)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SyntaxChecker::visit(StructDefinition const& _struct)
|
||||
{
|
||||
if (_struct.members().empty())
|
||||
m_errorReporter.syntaxError(_struct.location(), "Defining empty structs is disallowed.");
|
||||
return true;
|
||||
}
|
||||
|
@ -71,6 +71,8 @@ private:
|
||||
|
||||
virtual bool visit(VariableDeclaration const& _declaration) override;
|
||||
|
||||
virtual bool visit(StructDefinition const& _struct) override;
|
||||
|
||||
ErrorReporter& m_errorReporter;
|
||||
|
||||
/// Flag that indicates whether a function modifier actually contains '_'.
|
||||
|
@ -7279,7 +7279,7 @@ BOOST_AUTO_TEST_CASE(modifiers_access_storage_pointer)
|
||||
{
|
||||
char const* text = R"(
|
||||
contract C {
|
||||
struct S { }
|
||||
struct S { uint a; }
|
||||
modifier m(S storage x) {
|
||||
x;
|
||||
_;
|
||||
|
5
test/libsolidity/syntaxTests/empty_struct.sol
Normal file
5
test/libsolidity/syntaxTests/empty_struct.sol
Normal file
@ -0,0 +1,5 @@
|
||||
contract test {
|
||||
struct A {}
|
||||
}
|
||||
// ----
|
||||
// SyntaxError: Defining empty structs is disallowed.
|
Loading…
Reference in New Issue
Block a user