E4081#
The identifier is bound more than once in the same pattern.
It is not possible to bind two values to one identifier because they might have
different values. If you want to shadow the first identifier, you can use _ to
discard it.
Erroneous Example#
///|
fn f(a : Int?, b : Int?) -> Unit {
match (a, b) {
(Some(a), Some(a)) => println("Some(\{a})")
_ => println("None")
}
}
Suggestion#
Use a different name for the second identifier.
///|
fn f(a : Int?, b : Int?) -> Unit {
match (a, b) {
(Some(a), Some(b)) => println("Some(\{a}), Some(\{b})")
_ => println("None")
}
}
///|
test {
f(Some(1), Some(2))
}
If you want a shadow-like behavior here, you can explicitly discard the first
a using _:
///|
fn g(a : Int?, b : Int?) -> Unit {
match (a, b) {
(Some(_), Some(a)) => println("Some(\{a})")
_ => println("None")
}
}
///|
test {
g(Some(1), Some(2))
}