From 13e37df97c4585a68f2f7f4b6296cb38abc49cea Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 8 May 2018 15:11:28 +0100 Subject: Allow enums in interfaces --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 7 ------- libsolidity/analysis/TypeChecker.h | 1 - .../syntaxTests/nameAndTypeResolution/422_interface_enums.sol | 1 - 4 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Changelog.md b/Changelog.md index e00f74b3..762d91a9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -69,6 +69,7 @@ Language Features: * General: Allow appending ``calldata`` keyword to types, to explicitly specify data location for arguments of external functions. * General: Support ``pop()`` for storage arrays. * General: Scoping rules now follow the C99-style. + * General: Allow ``enum``s in interfaces. Compiler Features: * C API (``libsolc``): Export the ``solidity_license``, ``solidity_version`` and ``solidity_compile`` methods. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 7cec7c43..60637867 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -751,13 +751,6 @@ bool TypeChecker::visit(VariableDeclaration const& _variable) return false; } -bool TypeChecker::visit(EnumDefinition const& _enum) -{ - if (m_scope->contractKind() == ContractDefinition::ContractKind::Interface) - m_errorReporter.typeError(_enum.location(), "Enumerable cannot be declared in interfaces."); - return false; -} - void TypeChecker::visitManually( ModifierInvocation const& _modifier, vector const& _bases diff --git a/libsolidity/analysis/TypeChecker.h b/libsolidity/analysis/TypeChecker.h index 47892a3f..b696de85 100644 --- a/libsolidity/analysis/TypeChecker.h +++ b/libsolidity/analysis/TypeChecker.h @@ -96,7 +96,6 @@ private: virtual bool visit(StructDefinition const& _struct) override; virtual bool visit(FunctionDefinition const& _function) override; virtual bool visit(VariableDeclaration const& _variable) override; - virtual bool visit(EnumDefinition const& _enum) override; /// 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. void visitManually(ModifierInvocation const& _modifier, std::vector const& _bases); diff --git a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol index 5513817d..1533e7ff 100644 --- a/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol +++ b/test/libsolidity/syntaxTests/nameAndTypeResolution/422_interface_enums.sol @@ -2,4 +2,3 @@ interface I { enum A { B, C } } // ---- -// TypeError: (18-33): Enumerable cannot be declared in interfaces. -- cgit