-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Implement interface: allow compatible visibility #3458
Comments
Sorry I posted here, but it should have been #3412. OLD COMMENTAlso can we please evaluate if this test case should pass or fail:Test case 1pragma solidity ^0.4.20;
interface Math {
function calculateMostCommonNumberInSolidityDocumentation() external payable returns (int);
}
contract MathImplementation is Math {
function calculateMostCommonNumberInSolidityDocumentation() external returns (int) {
return 69;
}
} Test case 2pragma solidity ^0.4.20;
interface Math {
function calculateMostCommonNumberInSolidityDocumentation() external returns (int);
}
contract MathImplementation is Math {
function calculateMostCommonNumberInSolidityDocumentation() external payable returns (int) {
return 69;
}
} DiscussionIn the discussion of the deed/NFT/DAR standard ethereum/EIPs#841 we have specified which functions are payable and which are not. The 0x team argues that it is not in scope for a standard (an interface) to specify whether functions are payable. I think this discussion has wider applicability in the Solidity ecosystem so I have brought it here. |
I think the current specific rule in the code is that a contract implementing an interface may not modify the state mutability level of a function. State mutability is defined as (the only summary - there is also another suggestion to move selfdestruct into another state mutability level):
Above the state mutability level is increasing from pure (nothing) to payable (everything). What are the reasons proposed for disregarding the payable keyword for interfaces? |
Coming back to the initial proposal again: I think it should not be an error if a public function overrides an external function. The requirement for interface functions to be external makes their use extremely annoying. Because of that, I think this should be part of 0.5.0. |
Discussion
Currently,
interface
is meant to track ABI (again, I hate this word choice). Here is a contract that demonstratespublic
andexternal
functions do have identical ABI:And the ABI calculated by Solidity is:
Therefore, a contract that uses an
public
orexternal
function should be compatible with an interface that requires anexternal
function.Test case
This should produce no error. But currently the error is:
References
Related issues:
The text was updated successfully, but these errors were encountered: