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

Generic parameter propagation issue #1303

Open
dark64 opened this issue Apr 26, 2023 · 0 comments
Open

Generic parameter propagation issue #1303

dark64 opened this issue Apr 26, 2023 · 0 comments

Comments

@dark64
Copy link
Member

dark64 commented Apr 26, 2023

Description

Generic parameters are not propagated correctly when using structs

Environment

  • Compiler version: 0.8.6
  • Operating system: Ubuntu

Steps to Reproduce

struct Foo<N> {
    field[N] inner;
}

def test<N>() -> Foo<N> {
    return Foo { inner: [0; N] };
}

def main() -> Foo<2> {
    return test::<2>();
}

Fails to compile with message

Generic parameters must be compile-time constants, found test::<2>()

Assigning the result before returning works:

struct Foo<N> {
    field[N] inner;
}

def test<N>() -> Foo<N> {
    return Foo { inner: [0; N] };
}

def main() -> Foo<2> {
    Foo<2> foo = test::<2>();
    return foo;
}

Using an array directly without the struct compiles fine as expected which might suggest something regarding structs is not right:

def test<N>() -> field[N] {
    return [0; N];
}

def main() -> field[2] {
    return test::<2>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant