Skip to content

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

Closed
@certik

Description

@certik

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.

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