core
                                
                                
                                
                                    core copied to clipboard
                            
                            
                            
                        [Bug] Cannot define functions with the same signature in different contracts/interfaces
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);
  |                  ^^^^^^^^
                                    
                                    
                                    
                                
You should be able to work around this for now by creating separate sol! invocations for each interface.
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;
   |                      ^