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

Allow using complex type as array element type #730

Closed
Y-Nak opened this issue Jun 1, 2022 · 0 comments · Fixed by #734
Closed

Allow using complex type as array element type #730

Y-Nak opened this issue Jun 1, 2022 · 0 comments · Fixed by #734
Labels
comp: analyzer Everything that involves the analyzer pass type: feature

Comments

@Y-Nak
Copy link
Member

Y-Nak commented Jun 1, 2022

What is wrong?

Currently, array element types are restricted to primitive types.
Now, we can remove the restriction with the new codegen.

The test case below should be passed at least.

pub struct Pair {
    pub x: i32
    pub y: i32
}

contract Foo {
    pub fn static_sized_type_elem() -> Array<Pair, 2> {
        let pair1: Pair = Pair(x: 1, y: 2)
        let pair2: Pair = Pair(x: 10, y: 20)

        let arr: Array<Pair, 2> = [pair1, pair2]
        return arr
    }

    pub fn dynamic_sized_type_elem() -> Array<String<10>, u8>{
        let arr: Array<String<10>, 2> = ["Foo", "Bar"]
        return arr
    }
}

How can it be fixed

This can be fixed just by removing the restriction in the analyzer.
NOTE: It'd be better to wait for #729 to be merged because it will allow returning nested complex types.

@Y-Nak Y-Nak added type: feature comp: analyzer Everything that involves the analyzer pass labels Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: analyzer Everything that involves the analyzer pass type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant