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

In cross-call contract, ink! cannot pass compile for the parent contract contains event #1000

Open
atenjin opened this issue Nov 2, 2021 · 4 comments

Comments

@atenjin
Copy link

atenjin commented Nov 2, 2021

Questions
It's a bug in ink!, it may appear after pr #665

FAQ

ink! version: e8d4739
cargo-contract version: cargo-contract 0.15.0-unknown-x86_64-linux-gnu

Describe the bug
example repo:
https://github.com/atenjin/ink-event-bug

in this repo, test2 contract crate depends on test contract crate. So the contract Test2 in test2 will use the TestRef from the contract Test in test.

and in test/lib.rs:L20, I add a event definition, and do nothing.

    #[ink(event)]
    pub struct OtherThing;

and in test2/lib.rs:L23, I aslo define a event:

    #[ink(event)]
    pub struct Tmp;

and emit this event in following code, line 50

self.env().emit_event(Tmp {});

then in test2 directory, execute compile command, it cannot pass compile for the following error:

error[E0284]: type annotations needed
  --> /home/king/workspace/patractlabs/contracts/tmp/test2/lib.rs:50:24
   |
50 |             self.env().emit_event(Tmp {});
   |                        ^^^^^^^^^^ cannot infer type for type parameter `C` declared on the trait `EmitEvent`
   |
   = note: cannot satisfy `<_ as ContractEventBase>::Type == _`

if remove the emit_event, then Test2 can pass the compilation. But we need the event.

And If I remove the event definition in Test, then compiling Test2 can work normally.

and other people so in element, if I change the emit_event like this, can pass the compilation.

            // self.env().emit_event(Tmp {});
            ink_lang::codegen::EmitEvent::<Test2>::emit_event(self.env(), Tmp {});

Obviously, the type inference is broken when Test2 use the contract TestRef.

I think it can be fixed just changing some small part, right? @Robbepop

@DukeCaesar
Copy link

Same issue.

@cmichi
Copy link
Collaborator

cmichi commented May 12, 2022

@ascjones Do you have an idea if this will be fixed with #1243 ?

@ascjones
Copy link
Collaborator

Yes it will

@yeousunn
Copy link

I am having the same issue. Any idea how to go around it?

I am using ink version 4.2.1.

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

No branches or pull requests

5 participants