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

[Bug] Cannot define functions with the same signature in different contracts/interfaces #599

Closed
makcandrov opened this issue Apr 13, 2024 · 2 comments · Fixed by #694
Closed
Labels
bug Something isn't working

Comments

@makcandrov
Copy link

Component

sol! macro

What version of Alloy are you on?

0.7.0

Operating System

None

Describe the bug

alloy_sol_types::sol! {
    interface IERC20 {
        function transfer(address to, uint256 value) external returns (bool);
    }

    interface IERC721 {
        function transfer(address to, uint256 tokenId) external returns (bool);
    }
}
error: function with same name and parameter types defined twice
       
         = note: other declaration is here
       
 --> src\main.rs:3:18
  |
3 |         function transfer(address to, uint256 value) external returns (bool);
  |                  ^^^^^^^^

@makcandrov makcandrov added the bug Something isn't working label Apr 13, 2024
@DaniPopes
Copy link
Member

You should be able to work around this for now by creating separate sol! invocations for each interface.

@makcandrov
Copy link
Author

It doesn't work when you need to share something (like a structure) between the interfaces

alloy_sol_types::sol! {
    struct S {
        uint256 s;
    }

    interface Foo {
        function foo(S memory s) external;
    }
    
}

alloy_sol_types::sol! {
    interface Bar {
        function foo(S memory s) external;
    }
}
error: unresolved type
       
         = help: Custom types must be declared inside of the same scope they are referenced in,
       or "imported" as a UDT with `type ... is (...);`
       
  --> src\main.rs:14:22
   |
14 |         function foo(S memory s) external;
   |                      ^

error: unresolved custom type: S
  --> src\main.rs:14:22
   |
14 |         function foo(S memory s) external;
   |                      ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants