E0039
Parameter name used twice
ErrorEach parameter of a function or method needs a name of its own. A let or
let mut may reuse a name, a parameter's included: the new binding shadows the
old one from its declaration onwards.
Why
A call passes its arguments by position, but the body reads them by name. With
two parameters named a, a read of a could mean either argument.
Broken
fn add(a: i64, a: i64) -> i64 {
a + a
}
fn main() {
print(add(1, 2))
}
What sisu says
error[E0039]: `a` is already declared in this scope --> E0039.sisu:1:16 | 1 | fn add(a: i64, a: i64) -> i64 { | - ^ | | | first declared here sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0039
Fixed
fn add(a: i64, b: i64) -> i64 {
a + b
}
fn main() {
print(add(1, 2))
}
Sisu