You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would seem that the issue being discussed may be a problem with the solidity compiler. Perhaps it doesn't recognise that the virtual getters match the signature definintion for the interface functions or they haven't yet been created at the time it's checking for their presence.
The problem can be demonstrated with the following code:
pragma solidity^0.4.21;
interfaceERC20 {
function balanceOf(address) externalviewreturns (uint);
function transfer(address, uint) externalreturns (bool);
}
contractTestAisERC20 {
mapping(address=>uint) public balanceOf;
function TestA() public {
balanceOf[this] =1000;
}
function transfer(address_to, uint256_value) externalreturns (boolsuccess) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
require(balanceOf[_to] >= _value);
returntrue;
}
}
contractTestB {
address a;
function TestB() public {
a =newTestA();
}
function aBalance() externalviewreturns (uint) {
returnERC20(a).balanceOf(a);
}
}
If you try and compile this contract you will end up with an error like:
browser/contract.sol:28:13: TypeError: Trying to create an instance of an abstract contract.
a = new TestA();
^-------^
browser/contract.sol:4:5: Missing implementation:
function balanceOf(address) external view returns (uint);
^-------------------------------------------------------^
However if you remove the is ERC20 then it works fine.
Conversely if you add the getter function manually to TestA:
function balanceOf(address_to) externalviewreturns (uintvalue) {
return balanceOf[_to];
}
It also works fine.
The text was updated successfully, but these errors were encountered:
norganna
changed the title
Virtual getter functions don't exist yet when checking interfaces.
Virtual getter functions don't exist yet when checking inherited interface abstractness.
Apr 6, 2018
As per the discussion at https://ethereum.stackexchange.com/a/44964/34929
It would seem that the issue being discussed may be a problem with the solidity compiler. Perhaps it doesn't recognise that the virtual getters match the signature definintion for the interface functions or they haven't yet been created at the time it's checking for their presence.
The problem can be demonstrated with the following code:
If you try and compile this contract you will end up with an error like:
However if you remove the
is ERC20
then it works fine.Conversely if you add the getter function manually to
TestA
:It also works fine.
The text was updated successfully, but these errors were encountered: