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 contract's public state variable to implement interface function #3514

Closed
fulldecent opened this issue Feb 15, 2018 · 9 comments
Closed

Comments

@fulldecent
Copy link
Contributor

Test case

pragma solidity ^0.4.19;

interface I {
    function bob() external returns (int);
}

contract C is I {
    int public bob;
}

Current outcome

This contract does not implement all functions and thus cannot be created.

Expected outcome

Compiles successfully

Discussion

Getter functions are defined in the documentation at http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters:

The compiler automatically creates getter functions for all public state variables.

In contract C, the implicit function function bob() external returns (int); is generated for the public variable int public bob;. Therefore the contract should be a valid implementation of the interface.


References:

@fulldecent fulldecent changed the title Allow contact to implicitly implement interface Allow contact's public state variable to implement interface function Feb 15, 2018
fulldecent referenced this issue in Consensys/Tokens Feb 19, 2018
@chriseth
Copy link
Contributor

chriseth commented Mar 7, 2018

I fear we need a centralized point where we discuss how function inheritance is supposed to work in the future.

@fulldecent
Copy link
Contributor Author

Good point. In the Swift Evolution process, this would call for a manifesto. We could call it the Inheritance Manifesto. This would document what is going changing, the motivation and how to make the new behavior self-consistent.

If would like me to do this, maybe we could have a quick phone call. This will let me understand what type of end product would be accepted.

@axic
Copy link
Member

axic commented Mar 7, 2018

Well as a first step we should collect all the relevant issue numbers in one place. There are probably close to 10 issues talking about different facets of inheritance.

@fulldecent
Copy link
Contributor Author

fulldecent commented Mar 7, 2018

RUNNING TALLY:

@chriseth
Copy link
Contributor

chriseth commented Mar 9, 2018

@fulldecent I created a project https://github.com/ethereum/solidity/projects/9 - not sure if you can add items there, but if you tell me, I will add them.

@chriseth
Copy link
Contributor

chriseth commented Mar 9, 2018

Also created umbrella issue: #3698

@superduck35
Copy link

Interested to know the status of this as I seem to be getting some inconsistent behaviour between ~0.4.24 and 0.5.xx

@fulldecent
Copy link
Contributor Author

fulldecent commented May 30, 2019

@alsco77 This discussion is now rolled into #3729

This issue can be closed when the conclusion is reached, wherever that discussion happens.

@Marenz Marenz changed the title Allow contact's public state variable to implement interface function Allow contract's public state variable to implement interface function Dec 4, 2019
@chriseth
Copy link
Contributor

chriseth commented Dec 5, 2019

Implemented in #7839

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants