E0054#
Warning name: ambiguous_range_direction
The direction of an inclusive range is ambiguous.
This warning is emitted when an inclusive range such as 10..=0 is used in a
loop. The endpoints suggest a descending loop, but the range syntax does not
make the direction explicit.
Erroneous example#
///|
pub fn values() -> Array[Int] {
let result = []
for i in 10..=0 {
result.push(i)
}
result
}
Suggestion#
Use explicit descending range syntax when the loop should count down.
///|
pub fn values() -> Array[Int] {
let result = []
for i in 10>=..0 {
result.push(i)
}
result
}