Skip to content

Give an error message if function parameter is declared twice #1849

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

Closed
Tracked by #1802
certik opened this issue May 23, 2023 · 0 comments · Fixed by #1854
Closed
Tracked by #1802

Give an error message if function parameter is declared twice #1849

certik opened this issue May 23, 2023 · 0 comments · Fixed by #1854

Comments

@certik
Copy link
Contributor

certik commented May 23, 2023

This should give an error message that m is declared twice:

def init_X(m:i32, n: i32, b: CPtr, m: i32) -> None:
    B: Pointer[i16[m*n]] = c_p_pointer(b, i16[m*n])
    i: i32
    j: i32
    for i in range(m):
        for j in range(n):
            B[i * n + j] = i16((i + j) % m)

Clang gives the following error message on the generated code:

/Users/ondrej/repos/gsi/copperhead/benchmarks/matmul/build/mat_vec-host-generated.c:224:52: error: redefinition of parameter 'm'
void init_X(int32_t m, int32_t n, void* b, int32_t m)
                                                   ^
/Users/ondrej/repos/gsi/copperhead/benchmarks/matmul/build/mat_vec-host-generated.c:224:21: note: previous declaration is here
void init_X(int32_t m, int32_t n, void* b, int32_t m)
                    ^

We should give a similar error message, underlying both declarations of m.

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

Successfully merging a pull request may close this issue.

1 participant