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

Cannot import shadowed functions in Solidity 0.8.12 #12780

Closed
cleanunicorn opened this issue Mar 11, 2022 · 2 comments · Fixed by #12781
Closed

Cannot import shadowed functions in Solidity 0.8.12 #12780

cleanunicorn opened this issue Mar 11, 2022 · 2 comments · Fixed by #12781
Labels
bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine.

Comments

@cleanunicorn
Copy link

Description

Importing overloaded methods in Solidity 0.8.12 gives an error instead of loading the methods, even if the methods are not called.

Other info that might be relevant:

  • Checking the Solidity change list I found something that might be relevant

Inheritance: Consider functions in all ancestors during override analysis.

Environment

  • Compiler version: 0.8.12
  • Target EVM version (as per compiler settings): compiler default (but happens with all versions)
  • Framework/IDE (e.g. Truffle or Remix): Remix, but happens everywhere
  • EVM execution environment / backend / blockchain client: any
  • Operating system: any

Steps to Reproduce

Consider these 2 files created in Remix IDE

  • Math.sol - defines 2 methods, same name, different arguments
function sub(uint256 x, uint256 y) pure {}
function sub(uint256 x, int256 y) pure {}
  • ImportMath.sol - just tries to import the sub method
import {sub} from "./Math.sol";

Output error on compilation:

TypeError: No matching declaration found after variable lookup.
 --> ImportMath.sol:1:9:
  |
1 | import {sub} from "./Math.sol";
  |         ^^^

That means I don't know how to import those methods.

@chriseth
Copy link
Contributor

So how do we fix it? Just not perform overload resolution if the reference is inside an import statement?

@ekpyron
Copy link
Member

ekpyron commented Mar 14, 2022

We didn't do it before 0.8.12, so we should just keep not doing it, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 should compile without error Error is reported even though it shouldn't. Source is fine.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants