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

Using absolute paths with the new encoding will result in an error #5864

Open
hal3e opened this issue Apr 16, 2024 · 1 comment
Open

Using absolute paths with the new encoding will result in an error #5864

hal3e opened this issue Apr 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@hal3e
Copy link
Contributor

hal3e commented Apr 16, 2024

Using absolute paths with the new encoding will result in an error if different types have the same name.

contract;

mod contract_a_types;
mod another_lib;

use another_lib::VeryCommonNameStruct;

abi MyContract {
    fn test_function(arg: contract_a_types::VeryCommonNameStruct) -> VeryCommonNameStruct;
}

impl MyContract for Contract {
    fn test_function(_arg: contract_a_types::VeryCommonNameStruct) -> VeryCommonNameStruct {
        VeryCommonNameStruct { field_a: 10u32 }
    }
}

generates the following error:

3 |
4 |                     let args: (VeryCommonNameStruct,) = decode_second_param::<(VeryCommonNameStruct,)>();
5 |                     let result_test_function: raw_slice = encode::<VeryCommonNameStruct>(__contract_entry_test_function(args.0));
  |                                                                                                                         ^^^^^^ Mismatched types.
expected: VeryCommonNameStruct
found:    VeryCommonNameStruct.
help: The argument that has been provided to this function's type does not match the declared type of the parameter in the function declaration.
@jjcnn
Copy link
Contributor

jjcnn commented Jun 10, 2024

Steps to recreate, as described in #6044 by @hal3e :

I tried it with this branch but I still get an error. Unfortunately, I do not get any specifics just: error: Could not generate the entry method. See errors above for more details. and there is nothing above :/.
Steps to recreate:

  • clone fuels-rs and checkout hal3e/name-clash-abi-encode
  • cd into fuels-rs/e2e/sway/bindings/type_paths
  • forc build or forc build --json-abi-with-callpaths

P.S. I installed forc with:
cargo install --locked forc --force --git https://github.com/FuelLabs/sway --branch "jjcnn/name_clash_struct_def_glob_import"

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

No branches or pull requests

3 participants