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

bug: weak inference on simple type #5680

Closed
glihm opened this issue May 29, 2024 · 0 comments · Fixed by #5683
Closed

bug: weak inference on simple type #5680

glihm opened this issue May 29, 2024 · 0 comments · Fixed by #5683
Labels
bug Something isn't working

Comments

@glihm
Copy link

glihm commented May 29, 2024

Bug Report

Cairo version:

On commit 8d6b690cb1401e682a0aba7bcda3b40f00482572.

Current behavior:

The inference of very simple types seems to not be supported anymore, at least on LegacyMap that we had into the storage. It this expected as LegacyMap should be replaced by Map?
We had some cases also where it wasn't storage functions, and we had to insert multiple statements to guide the compiler with types.

In the present case, it was on a tuple.

Expected behavior:

Better inference, as it seemed to be? Because we observed that on long existing code.

Steps to reproduce:

#[starknet::contract]
mod c1 {
    #[starknet::interface]
    trait IMy<T> {
        fn a(self: @T);
    }

    #[storage]
    struct Storage {
        v1: LegacyMap::<felt252, (u32, u32)>,
    }

    #[abi(embed_v0)]
    impl My of IMy<ContractState> {
        fn a(self: @ContractState) {
            // This does not work.
            let (one, two) = self.v1.read(0);

            // This works.
            let a: (u32, u32) = self.v1.read(0);
            let (one, two) = a;
        }
    }
}

Other information:
The error printed:

error: Unexpected type for tuple pattern. "?3" is not a tuple.
 --> /private/tmp/test.cairo:16:17
            let (one, two) = self.v1.read(0);
                ^********^

We used to be on a different commit before seing this error: 25bef0b1d7d74e6eed560d46894b5d8fb9136dac.
On this commit, we don't have inference issues, everything compiles.

@glihm glihm added the bug Something isn't working label May 29, 2024
orizi added a commit that referenced this issue May 29, 2024
@orizi orizi linked a pull request May 29, 2024 that will close this issue
orizi added a commit that referenced this issue May 29, 2024
orizi added a commit that referenced this issue May 29, 2024
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

Successfully merging a pull request may close this issue.

1 participant