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

Incorrect codegen for trait methods #1530

Closed
kvinwang opened this issue Dec 8, 2022 · 4 comments
Closed

Incorrect codegen for trait methods #1530

kvinwang opened this issue Dec 8, 2022 · 4 comments
Labels
A-ink_lang [ink_lang] Work item A-ink_metadata [ink_metadata] Work item C-bug Something isn't working

Comments

@kvinwang
Copy link
Contributor

kvinwang commented Dec 8, 2022

Describe the bug
I am trying out the ink 4.0-beta.

Given the following trait definition:

#[ink::trait_definition(namespace = "pink_system")]
pub trait System {
    #[ink(message)]
    fn version(&self) -> (u16, u16);
}

The generated forwarder is:

impl<E> System for __ink_TraitCallBuilderSystem<E>
where
    E: ::ink::env::Environment,
{
    fn version(&self) -> Self::versionOutput {
        ::ink::env::call::build_call::<Self::Env>()
            .call_type(
                ::ink::env::call::Call::new()
                    .callee(::ink::ToAccountId::to_account_id(self)),
            )
            .exec_input(::ink::env::call::ExecutionInput::new(
                ::ink::env::call::Selector::new([0x87_u8, 0xC9_u8, 0x8A_u8, 0x8D_u8]),
            ))
            .returns::<(u16, u16)>()
    }
}

And also the metadata.json:

{
  "args": [],
  "docs": [],
  "label": "System::version",
  "mutates": false,
  "payable": false,
  "returnType": {
    "displayName": [],
    "type": 6
  },
  "selector": "0x87c98a8d"
},
...
{
"id": 6,
"type": {
  "def": {
    "tuple": [
      7,
      7
    ]
  }
}
},

Expected behavior
It should be:
.returns::<Result<(u16, u16),LangError>>()
and ditto in the metadata.

@ascjones
Copy link
Collaborator

ascjones commented Dec 8, 2022

I see the handling of LangError for traits was left as a follow-up in the @HCastano's original PR: #1450.

@HCastano HCastano added C-bug Something isn't working A-ink_lang [ink_lang] Work item A-ink_metadata [ink_metadata] Work item labels Dec 11, 2022
@kvinwang
Copy link
Contributor Author

kvinwang commented Feb 3, 2023

Hey guys,

I've noticed that 4.0.0-rc has been released.
Have the follow-ups in #1450 been done yet? This issue is definitely blocking us to upgrade to ink-4.0.

@ascjones
Copy link
Collaborator

ascjones commented Feb 3, 2023

Yes I believe the issues you have raised here are now fixed via #1525 (call builder return type) and #1531 (metadata). Can you double check and then we can close this issue?

@kvinwang
Copy link
Contributor Author

kvinwang commented Feb 4, 2023

Great, it works with 4.0.0-rc.

@kvinwang kvinwang closed this as completed Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ink_lang [ink_lang] Work item A-ink_metadata [ink_metadata] Work item C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants