Sisu
E0034

Name defined twice

Error

Built from the repository at commit a8614dc.

Functions, classes, enums and constants share one namespace. The fields and methods of a class share one, and so do the variants and methods of an enum. The labels of one variant's fields share one of their own, so two variants can use the same label. Each name is defined once in its namespace. The prelude functions print, eprint, panic and read_line are built in, so no function, class or constant can take their names.

Why

A call or a type that names a duplicate could mean either definition. Sisu keeps the first and reports the second.

Broken

fn double(n: i64) -> i64 {
    n * 2
}

fn double(n: i64) -> i64 {
    n + n
}

fn main() {
    print(double(2))
}

What sisu says

error[E0034]: function `double` is defined twice
 --> E0034.sisu:5:4
  |
1 | fn double(n: i64) -> i64 {
  |    ------ first defined here
...
5 | fn double(n: i64) -> i64 {
  |    ^^^^^^

sisu: 1 error
sisu: for more on a code, run `sisu explain <code>`: E0034

Fixed

fn double(n: i64) -> i64 {
    n * 2
}

fn main() {
    print(double(2))
}