Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow enums in interface #4087

Closed
axic opened this issue May 8, 2018 · 6 comments
Closed

Allow enums in interface #4087

axic opened this issue May 8, 2018 · 6 comments
Assignees
Labels
language design :rage4: Any changes to the language, e.g. new features

Comments

@axic
Copy link
Member

axic commented May 8, 2018

I believe this was raised previously a couple of times and it is handled as part of the inheritance discussion (#3729).

I'd however propose to make an exception and allow this simple change outside of concluding that discussion, right now.

Are there any reasons for disallowing it? I remember we disallowed it out of fear something might break (or rather lack of time to check everything) and probably enums weren't supported to be used from a foreign contract making it less useful.

However, as of today this should be working (granted bool TypeChecker::visit(EnumDefinition const& _enum) is removed in the type checker):

  enum X { A, B, C }
  function x() returns (I.X);
}

contract C is I {
  function x() returns (I.X) { return f(); }
  function f() returns (I.X) { return X.B; }
}

It also seems the output has the proper enum values after compilation.

@chriseth
Copy link
Contributor

I think it is fine to allow both enums and structs in interfaces.

@chriseth
Copy link
Contributor

I was never aware of any problem, we just wanted to restrict interfaces as much as possible.

@axic
Copy link
Member Author

axic commented May 15, 2018

I think it was rather lack of time to properly evaluate the implications and to get a basic version of interfaces out.

@chriseth
Copy link
Contributor

We should also allow structs.

@axic axic added the language design :rage4: Any changes to the language, e.g. new features label Jul 31, 2018
@axic axic self-assigned this Jul 31, 2018
@axic
Copy link
Member Author

axic commented Aug 7, 2018

I am working on this now.

@chriseth
Copy link
Contributor

chriseth commented Aug 7, 2018

Documentation change is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
language design :rage4: Any changes to the language, e.g. new features
Projects
None yet
Development

No branches or pull requests

2 participants