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

feature: aliasing for functions with duplicate names #1144

Closed
wants to merge 7 commits into from

Conversation

muse254
Copy link

@muse254 muse254 commented Feb 14, 2024

The changes introduced addresses #1084.
Concerned with aliasing colliding names in the generated abi using #[abi_alias(...)] as such:

trait T1{
   fn foo(&self);
}

trait T2 {
   fn foo(&self);
}

struct Contract;


impl T1 for Contract {
   fn foo(&self){
      log!("foo_one");
   }
}

impl T2 for Contract {
   #[abi_alias("foo_two")
   fn foo(&self){
      log!("foo_two");
   }
}

@muse254 muse254 marked this pull request as ready for review February 16, 2024 14:36
@muse254
Copy link
Author

muse254 commented Feb 16, 2024

@frol
Copy link
Collaborator

frol commented Feb 19, 2024

@muse254 I believe it does not address the problem raised in #1084. They had a problem when there are two functions with exactly the same names implemented for the same struct (through impl trait for ...). The problem is that #[near_bindgen] generates an extern "C" fn, which does not use a fully-qualified (unambiguous) syntax, and as such contract.foo() raises a compilation error. Also, I find abi_alias naming a bit confusing as for me it sounds like it will only be renamed in the ABI schema, and not in the contract itself, and "alias" implies that it will be reachable by both original and the alias names (I am not sure if that was intended)

P.S. The CI error is fixed in the upstream now, so I merged the latest changes from there to your PR branch.

@muse254
Copy link
Author

muse254 commented Feb 21, 2024

I'll look into understanding the problem and the repo some more and rework the solution. Thank you for taking your time to review ❤️

@frol frol marked this pull request as draft March 28, 2024 19:19
@frol
Copy link
Collaborator

frol commented Jun 1, 2024

This is taken over by #1186

@frol frol closed this Jun 1, 2024
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

Successfully merging this pull request may close these issues.

2 participants