Skip to content

Const generic arithmetic in array types not evaluated during unification #1372

Description

@micahscopes

Array types using const arithmetic like [T; N + 1] parse and check fine in the struct definition, but fail when instantiated because (1 + 1) isn't reduced to 2 for type matching.

struct G1 {
    pub x: u256,
    pub y: u256,
}

struct Vk<const N: usize> {
    pub ic: [G1; N + 1],
}

fn make_vk() -> Vk<1> {
    Vk {
        ic: [G1 { x: 3, y: 4 }, G1 { x: 5, y: 6 }],
    }
}
error: expected `[G1; (1 + 1)]`, but `[G1; 2]` is given

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions