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

Internal compiler error for call to unimplemented "super" function #5130

Closed
nweller opened this issue Oct 2, 2018 · 12 comments · Fixed by #5558
Closed

Internal compiler error for call to unimplemented "super" function #5130

nweller opened this issue Oct 2, 2018 · 12 comments · Fixed by #5558
Labels

Comments

@nweller
Copy link

nweller commented Oct 2, 2018

The following contract produces an internal compiler error in various solc versions, including the most recent build in Remix:

contract a {
    function f() public;
}
contract b is a {
    function f() public { super.f(); }
}

It does compile (but cannot be deployed due to the missing implementation) if I rename a.f().

(This report is part of an ICE Center@ETH Zurich project on automated compiler validation funded by the Ethereum Foundation.)

@axic axic added the bug 🐛 label Oct 2, 2018
@axic
Copy link
Member

axic commented Oct 2, 2018

Internal compiler error during compilation:
/Users/alex/Projects/solidity/libsolidity/codegen/ContractCompiler.cpp(893): Throw in function void dev::solidity::ContractCompiler::appendModifierOrFunctionCode()
Dynamic exception type: boost::exception_detail::clone_impl<dev::solidity::InternalCompilerError>
std::exception::what: 
[dev::tag_comment*] = 

@chriseth
Copy link
Contributor

chriseth commented Oct 2, 2018

What do you mean by "rename a.f()"? Can you post the full changed contract that does compile, please?

@nweller
Copy link
Author

nweller commented Oct 2, 2018

Sure - I meant that this compiles:

contract a {
    function f2() public;
}
contract b is a {
    function f() public { super.f2(); }  
}

This just shows that there's apparently some significance to having an implementation of the function in the sub class for the error to occur.

@chriseth
Copy link
Contributor

chriseth commented Oct 2, 2018

Great, thanks!

@anurag-git
Copy link
Contributor

@chriseth , would like to take up this issue. Let me know the strategy to proceed. I hope it is not too tricky.

@chriseth
Copy link
Contributor

chriseth commented Oct 8, 2018

It might work to just ignore functions that do not have implementations in ContractType::nativeMembers.

@anurag-git
Copy link
Contributor

anurag-git commented Nov 29, 2018

@chriseth, Did some analysis, let me know your thoughts


contract a {
    function f() public;
}
contract b is a {
   // function f() public { super.f(); }
    function f() public {uint i=0; uint j; j=i;}
}

This code compiles after changing the contract as above. As per the issue we are trying to call base contract function (which is not implemented) in derived contract, hence the error. Error seems to be expected as per my understanding.

Below code also compiles,


contract a {
    //function f() public;
    function f() pure public {
       uint i=0; uint j; j=i;
    }
}
contract b is a {
    function f() pure public { super.f(); }
    //function f() public { super.f(); }
}

which basically says that if base contract function is implemented things work fine.

So do we consider this (calling unimplemented base contract function) as valid? If so, then I can proceed with my analysis to fix this issue.

@chriseth
Copy link
Contributor

The initial code should result in an error stating something like super.f() is not available.

@anurag-git
Copy link
Contributor

@chriseth, I have a solution ready, please help me to write test case so that I can push both changes at once.

@chriseth
Copy link
Contributor

chriseth commented Dec 1, 2018

@anurag-git the initial code is a good test case. Put it in the syntaxTests directory and run isoltest. Use the update option if it prompts you for an action.

@dddejan
Copy link

dddejan commented Aug 21, 2019

If the super is changed to a in the original example, the compiler still fails with internal error.

contract a {
    function f() public;
}
contract b is a {
    function f() public { a.f(); }
}

@chriseth
Copy link
Contributor

The issue in the latest comment is tracked in #7314

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

Successfully merging a pull request may close this issue.

5 participants