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

Override error during sema phase #1561

Open
bkushigian opened this issue Oct 6, 2023 · 0 comments
Open

Override error during sema phase #1561

bkushigian opened this issue Oct 6, 2023 · 0 comments

Comments

@bkushigian
Copy link

The following code is a simplified/minimized version of OpenZeppelin's ERC721 contract:

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)

pragma solidity ^0.8.19;

interface IERC165 {
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

abstract contract ERC165 is IERC165 {
    function supportsInterface(
        bytes4 interfaceId
    ) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

abstract contract ERC721 is ERC165 {
    function supportsInterface(
        bytes4 interfaceId
    ) public view virtual override(ERC165) returns (bool) {
        return interfaceId == interfaceId;
    }
}

This compiles with solc:

$ solc testcase/override_errors/ERC721.sol 
Compiler run successful. No output generated.

but solang_parser fails to parse it:

$ solang_parser testcase/override_errors/ERC721.sol 

=====  Error: testcase/override_errors/ERC721.sol  =====
error: function 'supportsInterface' missing overrides 'IERC165', specify 'override(IERC165,ERC165)'
   ┌─ testcase/override_errors/ERC721.sol:21:27
   │
21 │     ) public view virtual override(ERC165) returns (bool) {
   │                           ^^^^^^^^^^^^^^^^

Further, solang_parser suggests the fix, which I have stored in
testcase/override_errors/ERC721_suggested_fix.sol. solc failes to compile this:

$ solc testcase/override_errors/ERC721_suggested_fix.sol 
Error: Invalid contract specified in override list: "IERC165".
  --> testcase/override_errors/ERC721_suggested_fix.sol:21:27:
   |
21 |     ) public view virtual override(IERC165, ERC165) returns (bool) {
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^
Note: This contract: 
 --> testcase/override_errors/ERC721_suggested_fix.sol:6:1:
  |
6 | interface IERC165 {
  | ^ (Relevant source part starts here and spans across multiple lines).

but solang_parser successfully parses it.

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

No branches or pull requests

2 participants
@bkushigian and others